diff --git a/CHANGELOG.md b/CHANGELOG.md index 333ba64..7312989 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ # Changelog ## [2.6.1] - 2024-08-30 +- Fix issue [#343](https://github.com/intersystems/language-server/issues/343): foldingRange fails on some C-style block comments - Fix issue [#344](https://github.com/intersystems/language-server/issues/344): Prevent errors during hover when no data was returned from the server ## [2.6.0] - 2024-08-29 diff --git a/server/src/providers/foldingRange.ts b/server/src/providers/foldingRange.ts index 1e4795f..304d2ce 100644 --- a/server/src/providers/foldingRange.ts +++ b/server/src/providers/foldingRange.ts @@ -699,15 +699,16 @@ export async function onFoldingRanges(params: FoldingRangeParams) { openranges.splice(prevrange,1); } else if (parsed[line][tkn].l == ld.cos_langindex && parsed[line][tkn].s == ld.cos_comment_attrindex) { + const commentText = doc.getText(Range.create(line,parsed[line][tkn].p,line,parsed[line][tkn].p+parsed[line][tkn].c)).trim(); const inCComment = openranges.length && openranges[openranges.length - 1].kind == "isc-ccomment"; - if (!inCComment && doc.getText(Range.create(line,parsed[line][tkn].p,line,parsed[line][tkn].p+2)) == "/*") { + if (!inCComment && commentText.slice(0,2) == "/*") { // Open a new C-style comment range openranges.push({ startLine: line, endLine: line, kind: "isc-ccomment" }); - } else if (inCComment && doc.getText(Range.create(line,parsed[line][tkn].p+parsed[line][tkn].c-2,line,parsed[line][tkn].p+parsed[line][tkn].c)) == "*/") { + } else if (inCComment && commentText.slice(-2) == "*/") { // Close the most recent C-style comment range const cCommentRange = openranges.pop(); cCommentRange.endLine = line - 1;