Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion packages/language-server/src/lib/documents/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -312,12 +312,14 @@ export function updateRelativeImport(oldPath: string, newPath: string, relativeI
*/
export function getNodeIfIsInComponentStartTag(
html: HTMLDocument,
document: Document,
offset: number
): Node | undefined {
const node = html.findNodeAt(offset);
if (
!!node.tag &&
node.tag[0] === node.tag[0].toUpperCase() &&
(node.tag[0] === node.tag[0].toUpperCase() ||
(document.isSvelte5 && node.tag.includes('.'))) &&
(!node.startTagEnd || offset < node.startTagEnd)
) {
return node;
Expand Down
2 changes: 1 addition & 1 deletion packages/language-server/src/plugins/html/HTMLPlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ export class HTMLPlugin
}

private isInComponentTag(html: HTMLDocument, document: Document, position: Position) {
return !!getNodeIfIsInComponentStartTag(html, document.offsetAt(position));
return !!getNodeIfIsInComponentStartTag(html, document, document.offsetAt(position));
}

private getLangCompletions(completions: CompletionItem[]): CompletionItem[] {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export function getComponentAtPosition(
return null;
}

const node = getNodeIfIsInComponentStartTag(doc.html, doc.offsetAt(originalPosition));
const node = getNodeIfIsInComponentStartTag(doc.html, doc, doc.offsetAt(originalPosition));
if (!node) {
return null;
}
Expand Down Expand Up @@ -80,7 +80,7 @@ export function isComponentAtPosition(
return false;
}

return !!getNodeIfIsInComponentStartTag(doc.html, doc.offsetAt(originalPosition));
return !!getNodeIfIsInComponentStartTag(doc.html, doc, doc.offsetAt(originalPosition));
}

export const IGNORE_START_COMMENT = '/*Ωignore_startΩ*/';
Expand Down
Loading