Skip to content

Commit 75fe403

Browse files
committed
minor fixes docs + replaceSuggestions
1 parent 5e0bc7a commit 75fe403

File tree

3 files changed

+18
-11
lines changed

3 files changed

+18
-11
lines changed

README.MD

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,9 +92,11 @@ You can quickly disable this plugin functionality by setting this setting to fal
9292
9393
### Vue Support
9494

95-
`.vue` SFC files support is enabled out of the box when [Vue Language Features (Volar)](https://marketplace.visualstudio.com/items?itemName=Vue.volar) is installed.
95+
`.vue` SFC files support is disabled, but can be enabled with setting and when [Vue Language Features (Volar)](https://marketplace.visualstudio.com/items?itemName=Vue.volar) is installed.
9696

97-
For the first time, it will configure `volar.vueserver.configFilePath` setting, to disable Vue support use `"tsEssentialPlugins.enableVueSupport": true` setting.
97+
Enable now: `"tsEssentialPlugins.enableVueSupport": true` (if you're not using local `./volar.config.js`)
98+
99+
For the first time, it will configure `volar.vueserver.configFilePath` setting.
98100

99101
This also makes plugin work in Volar's takeover mode!
100102

src/configurationType.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,21 @@ type ReplaceRule = {
66
* e.g. `readFile`, `^readFile` (global) or `fs.readFile`
77
*/
88
suggestion: string
9+
/**
10+
* Also its possible to specify any other completion properties. For example:
11+
* - sourceDisplay
12+
*/
913
filter?: {
1014
kind?: keyof Record<ScriptElementKind, string>
11-
/** doesn't support globs and not generally recommended */
12-
sourceDisplay?: boolean
1315
fileNamePattern?: string
1416
languageMode?: keyof typeof ScriptKind
1517
}
16-
/** by default only one entry is being proccessed */
18+
/** by default only first entry is proccessed */
1719
processMany?: boolean
1820
delete?: boolean
21+
/**
22+
* - true - original suggestion will be shown below current
23+
*/
1924
duplicateOriginal?: boolean | 'above'
2025
patch?: Partial<{
2126
name: string

typescript/src/completionsAtPosition.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ export const getCompletionsAtPosition = (
216216

217217
if (c('improveJsxCompletions') && leftNode) prior.entries = improveJsxCompletions(prior.entries, leftNode, position, sourceFile, c('jsxCompletionsMap'))
218218

219-
const processedEntryIdxs: number[] = []
219+
const processedEntries = new Set<ts.CompletionEntry>()
220220
for (const rule of c('replaceSuggestions')) {
221221
if (rule.filter?.fileNamePattern) {
222222
// todo replace with something better
@@ -242,8 +242,9 @@ export const getCompletionsAtPosition = (
242242
// todo-low (perf debt) clone probably should be used this
243243
const entry = prior!.entries[entryIndex]!
244244
if (rule.duplicateOriginal) {
245-
processedEntryIdxs.push(entryIndex + 1)
246-
prior!.entries.splice(rule.duplicateOriginal === 'above' ? entryIndex : entryIndex + 1, 0, { ...entry })
245+
const duplicateEntry = { ...entry }
246+
prior!.entries.splice(rule.duplicateOriginal === 'above' ? entryIndex : entryIndex + 1, 0, duplicateEntry)
247+
processedEntries.add(duplicateEntry)
247248
}
248249

249250
const { patch } = rule
@@ -259,12 +260,11 @@ export const getCompletionsAtPosition = (
259260
entry.insertText = entry.name
260261
}
261262
if (rule.patch?.insertText) entry.isSnippet = true
262-
processedEntryIdxs.push(entryIndex)
263-
prior!.entries.splice(entryIndex, 1, entry)
263+
processedEntries.add(entry)
264264
}
265265

266266
entry: for (const [i, entry] of prior!.entries.entries()) {
267-
if (processedEntryIdxs.includes(i)) continue
267+
if (processedEntries.has(entry)) continue
268268
const { name } = entry
269269
if (!nameComparator(name)) continue
270270
const { fileNamePattern, languageMode, ...simpleEntryFilters } = rule.filter ?? {}

0 commit comments

Comments
 (0)