Skip to content

Commit 8af8141

Browse files
authored
fix: don't show html tag completion with namespace component (#2685)
#2684 The problem is that the HTML tag completion takes priority over the ts completion and the TextEdit from HTML tag completion includes the whole dot notation. VSCode doesn't like it spans over the word span and filters it out.
1 parent a24d819 commit 8af8141

File tree

3 files changed

+6
-4
lines changed

3 files changed

+6
-4
lines changed

packages/language-server/src/lib/documents/utils.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -312,12 +312,14 @@ export function updateRelativeImport(oldPath: string, newPath: string, relativeI
312312
*/
313313
export function getNodeIfIsInComponentStartTag(
314314
html: HTMLDocument,
315+
document: Document,
315316
offset: number
316317
): Node | undefined {
317318
const node = html.findNodeAt(offset);
318319
if (
319320
!!node.tag &&
320-
node.tag[0] === node.tag[0].toUpperCase() &&
321+
(node.tag[0] === node.tag[0].toUpperCase() ||
322+
(document.isSvelte5 && node.tag.includes('.'))) &&
321323
(!node.startTagEnd || offset < node.startTagEnd)
322324
) {
323325
return node;

packages/language-server/src/plugins/html/HTMLPlugin.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ export class HTMLPlugin
217217
}
218218

219219
private isInComponentTag(html: HTMLDocument, document: Document, position: Position) {
220-
return !!getNodeIfIsInComponentStartTag(html, document.offsetAt(position));
220+
return !!getNodeIfIsInComponentStartTag(html, document, document.offsetAt(position));
221221
}
222222

223223
private getLangCompletions(completions: CompletionItem[]): CompletionItem[] {

packages/language-server/src/plugins/typescript/features/utils.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ export function getComponentAtPosition(
4141
return null;
4242
}
4343

44-
const node = getNodeIfIsInComponentStartTag(doc.html, doc.offsetAt(originalPosition));
44+
const node = getNodeIfIsInComponentStartTag(doc.html, doc, doc.offsetAt(originalPosition));
4545
if (!node) {
4646
return null;
4747
}
@@ -80,7 +80,7 @@ export function isComponentAtPosition(
8080
return false;
8181
}
8282

83-
return !!getNodeIfIsInComponentStartTag(doc.html, doc.offsetAt(originalPosition));
83+
return !!getNodeIfIsInComponentStartTag(doc.html, doc, doc.offsetAt(originalPosition));
8484
}
8585

8686
export const IGNORE_START_COMMENT = '/*Ωignore_startΩ*/';

0 commit comments

Comments
 (0)