Skip to content

Commit b40a259

Browse files
committed
fix comment bounds list bug
1 parent 33f2e0d commit b40a259

2 files changed

Lines changed: 27 additions & 8 deletions

File tree

CHANGELOG.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,19 @@ All notable changes to the "vscode-rascript" extension will be documented in thi
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## [[0.3.2](https://github.com/joshraphael/vscode-rascript/releases/tag/v0.3.2)] - 2025-XX-XX
9+
10+
[diff](https://github.com/joshraphael/vscode-rascript/compare/v0.3.1...v0.3.2)
11+
12+
### Added
13+
14+
### Changed
15+
16+
- Syntax highlighting to use upstream [rascript-syntax](https://github.com/joshraphael/rascript-syntax) repo
17+
- Bug involving incorrect comment bounds detected for hover, definition and completion data
18+
19+
### Removed
20+
821
## [[0.3.1](https://github.com/joshraphael/vscode-rascript/releases/tag/v0.3.1)] - 2025-08-07
922

1023
[diff](https://github.com/joshraphael/vscode-rascript/compare/v0.3.0...v0.3.1)

src/clients/shared/parser.ts

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -133,19 +133,23 @@ export function getScope(
133133
}
134134

135135
export function getCommentBoundsList(document: vscode.TextDocument) {
136+
console.log("test");
136137
let text = document.getText();
137138
let commentBounds: models.CommentBounds[] = [];
138139
let inComment = false;
139140
let tempStart = 0;
140-
for (let i = 0; i < text.length - 1; i++) {
141+
if (text.length < 2) {
142+
return commentBounds;
143+
}
144+
for (let i = 1; i < text.length; i++) {
141145
if (inComment) {
142-
if (text[i] === "\n" || text === "\r") {
146+
if (text[i] === "\n" || text[i] === "\r") {
143147
inComment = false;
144148
commentBounds.push({
145149
start: tempStart,
146-
end: i,
150+
end: i - 1,
147151
type: "Line",
148-
raw: text.slice(tempStart, i + 1),
152+
raw: text.slice(tempStart, i),
149153
});
150154
}
151155
} else {
@@ -160,7 +164,7 @@ export function getCommentBoundsList(document: vscode.TextDocument) {
160164
start: tempStart,
161165
end: i,
162166
type: "Line",
163-
raw: text.slice(tempStart, i + 1),
167+
raw: text.slice(tempStart),
164168
});
165169
}
166170
}
@@ -173,16 +177,18 @@ export function getCommentBoundsList(document: vscode.TextDocument) {
173177
for (let i = 1; i < text.length; i++) {
174178
if (inComment) {
175179
if (text[i - 1] + text[i] === "*/") {
180+
// end
176181
inComment = false;
177182
commentBounds.push({
178183
start: tempStart,
179-
end: i,
184+
end: i - 1,
180185
type: "Block",
181-
raw: text.slice(tempStart, i + 1),
186+
raw: text.slice(tempStart, i),
182187
});
183188
}
184189
} else {
185190
if (text[i - 1] + text[i] === "/*") {
191+
// start
186192
inComment = true;
187193
tempStart = i - 1;
188194
}
@@ -193,7 +199,7 @@ export function getCommentBoundsList(document: vscode.TextDocument) {
193199
start: tempStart,
194200
end: i,
195201
type: "Block",
196-
raw: text.slice(tempStart, i + 1),
202+
raw: text.slice(tempStart),
197203
});
198204
}
199205
}

0 commit comments

Comments
 (0)