Skip to content

Commit dedde3f

Browse files
committed
Fixes #386
1 parent d4c5808 commit dedde3f

File tree

2 files changed

+24
-5
lines changed

2 files changed

+24
-5
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
## [2.8.1] - 2025-XX-XX
44
- Fix issue [#381](https://github.com/intersystems/language-server/issues/381): Fix extension crashes due to request forwarding
5+
- Fix issue [#386](https://github.com/intersystems/language-server/issues/386): No folding range added for methods with `Language = python` on Windows
56

67
## [2.8.0] - 2025-07-28
78
- Fix issue [#378](https://github.com/intersystems/language-server/issues/378): Remove `intersystems.language-server.completion.showInternal` setting

server/src/providers/foldingRange.ts

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,22 @@ export async function onFoldingRanges(params: FoldingRangeParams) {
1111
if (doc === undefined) {return null;}
1212
const parsed = await getParsedDocument(params.textDocument.uri);
1313
if (parsed === undefined) {return null;}
14+
/**
15+
* Returns `true` if the given line is the opening of a class member range.
16+
* This is needed for the rare case where the open curly brace is not the
17+
* last semantic token on the line even though it is the last character.
18+
* The only known instance of this happening is for `Language = python`
19+
* methods on Windows, which is caused by an underlying parser bug.
20+
*/
21+
const isClassMemberOpen = (line: number): boolean => {
22+
if (doc.languageId != "objectscript-class") return false;
23+
const lineText = doc.getText(Range.create(line,0,line+1,0));
24+
if (lineText.trimEnd().endsWith("{")) {
25+
const openCurlyIdx = lineText.lastIndexOf("{");
26+
return (parsed[line] ?? []).some((t) => openCurlyIdx == t.p && t.l == ld.cls_langindex && t.s == ld.cls_delim_attrindex);
27+
}
28+
return false;
29+
};
1430
const result: FoldingRange[] = [];
1531

1632
const openranges: FoldingRange[] = [];
@@ -95,11 +111,13 @@ export async function onFoldingRanges(params: FoldingRangeParams) {
95111
}
96112
}
97113
if (
98-
parsed[line][parsed[line].length-1].l == ld.cls_langindex && parsed[line][parsed[line].length-1].s == ld.cls_delim_attrindex &&
99-
doc.getText(Range.create(
100-
line,parsed[line][parsed[line].length-1].p,
101-
line,parsed[line][parsed[line].length-1].p+parsed[line][parsed[line].length-1].c
102-
)) == "{"
114+
(
115+
parsed[line][parsed[line].length-1].l == ld.cls_langindex && parsed[line][parsed[line].length-1].s == ld.cls_delim_attrindex &&
116+
doc.getText(Range.create(
117+
line,parsed[line][parsed[line].length-1].p,
118+
line,parsed[line][parsed[line].length-1].p+parsed[line][parsed[line].length-1].c
119+
)) == "{"
120+
) || isClassMemberOpen(line)
103121
) {
104122
// This line ends with a UDL open curly
105123

0 commit comments

Comments
 (0)