Skip to content

Commit

Permalink
fix: auto-complete break language server when "jsx": "preserve" mis…
Browse files Browse the repository at this point in the history
…sing

close #1171
  • Loading branch information
johnsoncodehk committed Apr 12, 2022
1 parent 870bd42 commit 0c52204
Showing 1 changed file with 10 additions and 4 deletions.
Expand Up @@ -758,21 +758,27 @@ 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.filter(entry => entry.kind !== 'warning') ?? [];
try {
bind = options.tsRuntime.getTsLs().getCompletionsAtPosition(file.fileName, offset, undefined)?.entries.filter(entry => entry.kind !== 'warning') ?? [];
} catch { }
}
}
{
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.filter(entry => entry.kind !== 'warning') ?? [];
try {
on = options.tsRuntime.getTsLs().getCompletionsAtPosition(file.fileName, offset, undefined)?.entries.filter(entry => entry.kind !== 'warning') ?? [];
} catch { }
}
}
cache.set(tag.name, { item: tag.item, bind, on });
}
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: [] });
try {
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: [] });
} catch { }
}

componentCompletionDataCache.set(templateData, cache);
Expand Down

0 comments on commit 0c52204

Please sign in to comment.