diff --git a/package.json b/package.json index bd6432d9..e9904ba5 100644 --- a/package.json +++ b/package.json @@ -80,7 +80,7 @@ "onLanguage:typescriptreact" ], "scripts": { - "start": "vscode-framework start", + "start": "vscode-framework start --skip-launching", "build": "tsc && tsc -p typescript --noEmit && vscode-framework build && pnpm build-plugin", "build-plugin": "node buildTsPlugin.mjs && node buildTsPlugin.mjs --browser", "watch-plugin": "node buildTsPlugin.mjs --watch", diff --git a/typescript/src/completions/filterWIthIgnoreAutoImports.ts b/typescript/src/completions/ignoreAutoImports.ts similarity index 77% rename from typescript/src/completions/filterWIthIgnoreAutoImports.ts rename to typescript/src/completions/ignoreAutoImports.ts index 74ff4030..98de176a 100644 --- a/typescript/src/completions/filterWIthIgnoreAutoImports.ts +++ b/typescript/src/completions/ignoreAutoImports.ts @@ -6,8 +6,9 @@ import { sortBy } from 'rambda' export default (entries: ts.CompletionEntry[], languageService: ts.LanguageService, c: GetConfig) => { const ignoreAutoImportsSetting = getIgnoreAutoImportSetting(c) - let newEntries = entries.filter(({ sourceDisplay, name }) => { - if (!sourceDisplay) return true + const ignoreKinds = [ts.ScriptElementKind.warning, ts.ScriptElementKind.string] + entries = entries.filter(({ sourceDisplay, name, kind }) => { + if (!sourceDisplay || ignoreKinds.includes(kind)) return true const targetModule = ts.displayPartsToString(sourceDisplay) const toIgnore = isAutoImportEntryShouldBeIgnored(ignoreAutoImportsSetting, targetModule, name) return !toIgnore @@ -15,7 +16,7 @@ export default (entries: ts.CompletionEntry[], languageService: ts.LanguageServi // todo I'm not sure of incomplete completion (wasnt tested) // todo don't forget to impl glob there const handledSymbolNames = new Set() - for (const [i, entry] of newEntries.entries()) { + for (const [i, entry] of entries.entries()) { const { name } = entry if (!entry.sourceDisplay || handledSymbolNames.has(name)) continue if (!shouldChangeSortingOfAutoImport(name, c)) continue @@ -23,7 +24,7 @@ export default (entries: ts.CompletionEntry[], languageService: ts.LanguageServi const sortFn = changeSortingOfAutoImport(c, name) // TODO probably should be rewrited const entriesToSort: ts.CompletionEntry[] = [] - newEntries = newEntries.filter((entry, k) => { + entries = entries.filter((entry, k) => { if (k < i) return true if (entry.sourceDisplay && entry.name === name) { entriesToSort.push(entry) @@ -33,7 +34,7 @@ export default (entries: ts.CompletionEntry[], languageService: ts.LanguageServi }) // todo rewrite outer that for loop to index based and increment here on insert length + handledSymbolNames can be removed in that case // final one seems to be slow, e.g. it might be slowing down completions - newEntries.splice(i, 0, ...sortBy(({ sourceDisplay }) => sortFn(ts.displayPartsToString(sourceDisplay)), entriesToSort)) + entries.splice(i, 0, ...sortBy(({ sourceDisplay }) => sortFn(ts.displayPartsToString(sourceDisplay)), entriesToSort)) } - return newEntries + return entries } diff --git a/typescript/src/completionsAtPosition.ts b/typescript/src/completionsAtPosition.ts index e80dc189..16935e74 100644 --- a/typescript/src/completionsAtPosition.ts +++ b/typescript/src/completionsAtPosition.ts @@ -21,7 +21,7 @@ import objectLiteralCompletions from './completions/objectLiteralCompletions' import filterJsxElements from './completions/filterJsxComponents' import markOrRemoveGlobalCompletions from './completions/markOrRemoveGlobalLibCompletions' import { oneOf } from '@zardoy/utils' -import filterWIthIgnoreAutoImports from './completions/filterWIthIgnoreAutoImports' +import filterWIthIgnoreAutoImports from './completions/ignoreAutoImports' export type PrevCompletionMap = Record @@ -177,7 +177,7 @@ export const getCompletionsAtPosition = ( if (node) prior.entries = defaultHelpers(prior.entries, node, languageService) ?? prior.entries if (exactNode) prior.entries = objectLiteralCompletions(prior.entries, exactNode, languageService, options ?? {}, c) ?? prior.entries // 90% - if (prior.isGlobalCompletion) prior.entries = filterWIthIgnoreAutoImports(prior.entries, languageService, c) + prior.entries = filterWIthIgnoreAutoImports(prior.entries, languageService, c) const inKeywordCompletionsResult = inKeywordCompletions(position, node, sourceFile, program, languageService) if (inKeywordCompletionsResult) { diff --git a/vscode-framework.config.js b/vscode-framework.config.js index 859c4efd..a5092234 100644 --- a/vscode-framework.config.js +++ b/vscode-framework.config.js @@ -14,10 +14,6 @@ patchPackageJson({ module.exports = defineConfig({ consoleStatements: process.argv.includes('--web') ? false : undefined, - development: { - // @ts-ignore - executable: '---------', - }, target: { web: true, desktop: true,