@volar/typescript 2.0.1-patch.1 → 2.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -421,18 +421,41 @@ function decorateLanguageService(files, languageService) {
|
|
|
421
421
|
languageService.getCompletionsAtPosition = (fileName, position, options, formattingSettings) => {
|
|
422
422
|
const [virtualCode, sourceFile, map] = (0, utils_1.getVirtualFileAndMap)(files, fileName);
|
|
423
423
|
if (virtualCode) {
|
|
424
|
+
let mainResult;
|
|
425
|
+
let additionalResults = [];
|
|
424
426
|
for (const [generateOffset, mapping] of map.getGeneratedOffsets(position)) {
|
|
425
427
|
if ((0, language_core_1.isCompletionEnabled)(mapping.data)) {
|
|
428
|
+
const isAdditional = typeof mapping.data.completion === 'object' && mapping.data.completion.isAdditional;
|
|
429
|
+
if (!isAdditional && mainResult) {
|
|
430
|
+
continue;
|
|
431
|
+
}
|
|
426
432
|
const result = getCompletionsAtPosition(fileName, generateOffset + sourceFile.snapshot.getLength(), options, formattingSettings);
|
|
427
433
|
if (result) {
|
|
428
434
|
for (const entry of result.entries) {
|
|
429
435
|
entry.replacementSpan = (0, transform_1.transformSpan)(files, fileName, entry.replacementSpan, language_core_1.isCompletionEnabled)?.textSpan;
|
|
430
436
|
}
|
|
431
437
|
result.optionalReplacementSpan = (0, transform_1.transformSpan)(files, fileName, result.optionalReplacementSpan, language_core_1.isCompletionEnabled)?.textSpan;
|
|
438
|
+
if (isAdditional) {
|
|
439
|
+
additionalResults.push(result);
|
|
440
|
+
}
|
|
441
|
+
else {
|
|
442
|
+
mainResult = result;
|
|
443
|
+
}
|
|
432
444
|
}
|
|
433
|
-
return result;
|
|
434
445
|
}
|
|
435
446
|
}
|
|
447
|
+
if (!mainResult && additionalResults.length) {
|
|
448
|
+
mainResult = additionalResults.shift();
|
|
449
|
+
}
|
|
450
|
+
if (mainResult) {
|
|
451
|
+
return {
|
|
452
|
+
...mainResult,
|
|
453
|
+
entries: [
|
|
454
|
+
...mainResult.entries,
|
|
455
|
+
...additionalResults.map(additionalResult => additionalResult.entries).flat(),
|
|
456
|
+
],
|
|
457
|
+
};
|
|
458
|
+
}
|
|
436
459
|
}
|
|
437
460
|
else {
|
|
438
461
|
return getCompletionsAtPosition(fileName, position, options, formattingSettings);
|
|
@@ -108,10 +108,11 @@ function createLanguage(ts, sys, languagePlugins, configFileName, projectHost, {
|
|
|
108
108
|
getCurrentDirectory: projectHost.getCurrentDirectory,
|
|
109
109
|
getCompilationSettings() {
|
|
110
110
|
const options = projectHost.getCompilationSettings();
|
|
111
|
-
if (languagePlugins.some(language => language.typescript?.extraFileExtensions.length)
|
|
112
|
-
&& !options.allowNonTsExtensions) {
|
|
113
|
-
console.warn('`allowNonTsExtensions` must be `true`.');
|
|
111
|
+
if (languagePlugins.some(language => language.typescript?.extraFileExtensions.length)) {
|
|
114
112
|
options.allowNonTsExtensions ??= true;
|
|
113
|
+
if (!options.allowNonTsExtensions) {
|
|
114
|
+
console.warn('`allowNonTsExtensions` must be `true`.');
|
|
115
|
+
}
|
|
115
116
|
}
|
|
116
117
|
return options;
|
|
117
118
|
},
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@volar/typescript",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.2",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"files": [
|
|
6
6
|
"**/*.js",
|
|
@@ -12,12 +12,13 @@
|
|
|
12
12
|
"directory": "packages/typescript"
|
|
13
13
|
},
|
|
14
14
|
"dependencies": {
|
|
15
|
-
"@volar/language-core": "2.0.
|
|
15
|
+
"@volar/language-core": "2.0.2",
|
|
16
16
|
"path-browserify": "^1.0.1"
|
|
17
17
|
},
|
|
18
18
|
"devDependencies": {
|
|
19
19
|
"@types/node": "latest",
|
|
20
20
|
"@types/path-browserify": "latest",
|
|
21
|
-
"@volar/language-service": "2.0.
|
|
22
|
-
}
|
|
21
|
+
"@volar/language-service": "2.0.2"
|
|
22
|
+
},
|
|
23
|
+
"gitHead": "ae8bccc570e6ee752693b1bfd9e815668b5f32b9"
|
|
23
24
|
}
|