Skip to content

Commit

Permalink
fix: attrs auto-complete and tag highlight incorrect on js project
Browse files Browse the repository at this point in the history
close #1158
  • Loading branch information
johnsoncodehk committed Apr 11, 2022
1 parent d004ad2 commit 31e6a2b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
Expand Up @@ -758,20 +758,20 @@ export default function <T extends ReturnType<typeof useHtmlPlugin>>(options: {
let offset = file.content.indexOf(searchText);
if (offset >= 0) {
offset += searchText.length;
bind = options.tsRuntime.getTsLs().getCompletionsAtPosition(file.fileName, offset, undefined)?.entries ?? [];
bind = options.tsRuntime.getTsLs().getCompletionsAtPosition(file.fileName, offset, undefined)?.entries.filter(entry => entry.kind !== 'warning') ?? [];
}
}
{
const searchText = SearchTexts.EmitCompletion(tag.name);
let offset = file.content.indexOf(searchText);
if (offset >= 0) {
offset += searchText.length;
on = options.tsRuntime.getTsLs().getCompletionsAtPosition(file.fileName, offset, undefined)?.entries ?? [];
on = options.tsRuntime.getTsLs().getCompletionsAtPosition(file.fileName, offset, undefined)?.entries.filter(entry => entry.kind !== 'warning') ?? [];
}
}
cache.set(tag.name, { item: tag.item, bind, on });
}
const globalBind = options.tsRuntime.getTsLs().getCompletionsAtPosition(file.fileName, file.content.indexOf(SearchTexts.GlobalAttrs), undefined)?.entries ?? [];
const globalBind = options.tsRuntime.getTsLs().getCompletionsAtPosition(file.fileName, file.content.indexOf(SearchTexts.GlobalAttrs), undefined)?.entries.filter(entry => entry.kind !== 'warning') ?? [];
cache.set('*', { item: undefined, bind: globalBind, on: [] });
}

Expand Down
2 changes: 1 addition & 1 deletion packages/vue-typescript/src/vueFile.ts
Expand Up @@ -527,7 +527,7 @@ export function createVueFile(
// getSourceFile return undefined for lang=js with allowJs=false;
!!tsLs.getProgram()?.getSourceFile(file.fileName);

let components = hasFile ? tsLs.getCompletionsAtPosition(file!.fileName, file!.content.indexOf(SearchTexts.Components), options)?.entries ?? [] : [];
let components = hasFile ? tsLs.getCompletionsAtPosition(file!.fileName, file!.content.indexOf(SearchTexts.Components), options)?.entries.filter(entry => entry.kind !== ts.ScriptElementKind.warning) ?? [] : [];

components = components.filter(entry => {
return entry.name.indexOf('$') === -1 && !entry.name.startsWith('_');
Expand Down

0 comments on commit 31e6a2b

Please sign in to comment.