Skip to content

Commit 082bc56

Browse files
committed
Fixes #374
1 parent fd7ce95 commit 082bc56

File tree

2 files changed

+22
-19
lines changed

2 files changed

+22
-19
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.7.4] - 2025-XX-XX
44
- Fix issue [#373](https://github.com/intersystems/language-server/issues/373): Add go to definition and hover support for `UrlMap` Call and Forward attribute values
5+
- Fix issue [#374](https://github.com/intersystems/language-server/issues/374): `undefined` items appearing in completion lists for XML XData
56

67
## [2.7.3] - 2025-05-05
78
- Fix issue [#366](https://github.com/intersystems/language-server/issues/366): Language Server can return invalid DocumentSymbols in some rare circumstances

server/src/providers/completion.ts

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1801,14 +1801,14 @@ export async function onCompletion(params: CompletionParams): Promise<Completion
18011801
if (parsed[j][k].l == ld.cls_langindex && parsed[j][k].s == ld.cls_keyword_attrindex) {
18021802
// This is a UDL trailing keyword
18031803
const keytext = doc.getText(Range.create(
1804-
Position.create(j,parsed[j][k].p),
1805-
Position.create(j,parsed[j][k].p+parsed[j][k].c)
1804+
j,parsed[j][k].p,
1805+
j,parsed[j][k].p+parsed[j][k].c
18061806
)).toLowerCase();
18071807
if (keytext === "xmlnamespace") {
18081808
// An XMLNamespace is defined
18091809
xmlns = doc.getText(Range.create(
1810-
Position.create(j,parsed[j][k+2].p+1),
1811-
Position.create(j,parsed[j][k+2].p+parsed[j][k+2].c-1)
1810+
j,parsed[j][k+2].p+1,
1811+
j,parsed[j][k+2].p+parsed[j][k+2].c-1
18121812
));
18131813
break;
18141814
}
@@ -1857,21 +1857,21 @@ export async function onCompletion(params: CompletionParams): Promise<Completion
18571857
if (parsed[xmlline][xmltkn].l == ld.xml_langindex && parsed[xmlline][xmltkn].s == ld.xml_tagdelim_attrindex) {
18581858
// This is a tag delimiter
18591859
const tokentext = doc.getText(Range.create(
1860-
Position.create(xmlline,parsed[xmlline][xmltkn].p),
1861-
Position.create(xmlline,parsed[xmlline][xmltkn].p+parsed[xmlline][xmltkn].c)
1860+
xmlline,parsed[xmlline][xmltkn].p,
1861+
xmlline,parsed[xmlline][xmltkn].p+parsed[xmlline][xmltkn].c
18621862
));
18631863
if (tokentext === "<") {
18641864
// The upcoming element is being opened
18651865
openelem.push(doc.getText(Range.create(
1866-
Position.create(xmlline,parsed[xmlline][xmltkn+1].p),
1867-
Position.create(xmlline,parsed[xmlline][xmltkn+1].p+parsed[xmlline][xmltkn+1].c)
1866+
xmlline,parsed[xmlline][xmltkn+1].p,
1867+
xmlline,parsed[xmlline][xmltkn+1].p+parsed[xmlline][xmltkn+1].c
18681868
)));
18691869
}
18701870
else if (tokentext === "</") {
18711871
// The upcoming element is being closed
18721872
openelem.splice(openelem.lastIndexOf(doc.getText(Range.create(
1873-
Position.create(xmlline,parsed[xmlline][xmltkn+1].p),
1874-
Position.create(xmlline,parsed[xmlline][xmltkn+1].p+parsed[xmlline][xmltkn+1].c)
1873+
xmlline,parsed[xmlline][xmltkn+1].p,
1874+
xmlline,parsed[xmlline][xmltkn+1].p+parsed[xmlline][xmltkn+1].c
18751875
))),1);
18761876
}
18771877
else if (tokentext === "/>") {
@@ -1935,13 +1935,15 @@ export async function onCompletion(params: CompletionParams): Promise<Completion
19351935
});
19361936
}
19371937

1938-
// Create the completion item for the closing tag
1939-
result.push({
1940-
label: "/"+openelem[openelem.length-1]+">",
1941-
kind: CompletionItemKind.Property,
1942-
data: "SASchema",
1943-
sortText: "zzzzz"+"/"+openelem[openelem.length-1]+">"
1944-
});
1938+
if (openelem.length) {
1939+
// Create the completion item for the closing tag
1940+
result.push({
1941+
label: "/"+openelem[openelem.length-1]+">",
1942+
kind: CompletionItemKind.Property,
1943+
data: "SASchema",
1944+
sortText: "zzzzz"+"/"+openelem[openelem.length-1]+">"
1945+
});
1946+
}
19451947
}
19461948
else {
19471949
// Looking for an attribute value enum
@@ -1955,8 +1957,8 @@ export async function onCompletion(params: CompletionParams): Promise<Completion
19551957
if (parsed[params.position.line][tkn].l == ld.xml_langindex && parsed[params.position.line][tkn].s == ld.xml_attr_attrindex) {
19561958
// This is an attribute name
19571959
selector = doc.getText(Range.create(
1958-
Position.create(params.position.line,parsed[params.position.line][tkn].p),
1959-
Position.create(params.position.line,parsed[params.position.line][tkn].p+parsed[params.position.line][tkn].c)
1960+
params.position.line,parsed[params.position.line][tkn].p,
1961+
params.position.line,parsed[params.position.line][tkn].p+parsed[params.position.line][tkn].c
19601962
));
19611963
break;
19621964
}

0 commit comments

Comments
 (0)