Skip to content

Commit 6968929

Browse files
authored
Merge pull request #9 from joshraphael/fix_comment_bounds
fix comment bounds list bug
2 parents 33f2e0d + 09260c2 commit 6968929

2 files changed

Lines changed: 26 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: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -137,15 +137,18 @@ export function getCommentBoundsList(document: vscode.TextDocument) {
137137
let commentBounds: models.CommentBounds[] = [];
138138
let inComment = false;
139139
let tempStart = 0;
140-
for (let i = 0; i < text.length - 1; i++) {
140+
if (text.length < 2) {
141+
return commentBounds;
142+
}
143+
for (let i = 1; i < text.length; i++) {
141144
if (inComment) {
142-
if (text[i] === "\n" || text === "\r") {
145+
if (text[i] === "\n" || text[i] === "\r") {
143146
inComment = false;
144147
commentBounds.push({
145148
start: tempStart,
146-
end: i,
149+
end: i - 1,
147150
type: "Line",
148-
raw: text.slice(tempStart, i + 1),
151+
raw: text.slice(tempStart, i),
149152
});
150153
}
151154
} else {
@@ -160,7 +163,7 @@ export function getCommentBoundsList(document: vscode.TextDocument) {
160163
start: tempStart,
161164
end: i,
162165
type: "Line",
163-
raw: text.slice(tempStart, i + 1),
166+
raw: text.slice(tempStart),
164167
});
165168
}
166169
}
@@ -173,16 +176,18 @@ export function getCommentBoundsList(document: vscode.TextDocument) {
173176
for (let i = 1; i < text.length; i++) {
174177
if (inComment) {
175178
if (text[i - 1] + text[i] === "*/") {
179+
// end
176180
inComment = false;
177181
commentBounds.push({
178182
start: tempStart,
179-
end: i,
183+
end: i - 1,
180184
type: "Block",
181-
raw: text.slice(tempStart, i + 1),
185+
raw: text.slice(tempStart, i),
182186
});
183187
}
184188
} else {
185189
if (text[i - 1] + text[i] === "/*") {
190+
// start
186191
inComment = true;
187192
tempStart = i - 1;
188193
}
@@ -193,7 +198,7 @@ export function getCommentBoundsList(document: vscode.TextDocument) {
193198
start: tempStart,
194199
end: i,
195200
type: "Block",
196-
raw: text.slice(tempStart, i + 1),
201+
raw: text.slice(tempStart),
197202
});
198203
}
199204
}

0 commit comments

Comments
 (0)