@volar/typescript 2.0.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);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type FileRegistry } from '@volar/language-core';
|
|
2
2
|
import type * as ts from 'typescript';
|
|
3
3
|
export declare function decorateLanguageServiceHost(virtualFiles: FileRegistry, languageServiceHost: ts.LanguageServiceHost, ts: typeof import('typescript')): void;
|
|
4
4
|
export declare function searchExternalFiles(ts: typeof import('typescript'), project: ts.server.Project, exts: string[]): string[];
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.searchExternalFiles = exports.decorateLanguageServiceHost = void 0;
|
|
4
|
-
const
|
|
4
|
+
const language_core_1 = require("@volar/language-core");
|
|
5
5
|
function decorateLanguageServiceHost(virtualFiles, languageServiceHost, ts) {
|
|
6
6
|
let extraProjectVersion = 0;
|
|
7
7
|
const exts = virtualFiles.languagePlugins
|
|
@@ -118,7 +118,7 @@ function decorateLanguageServiceHost(virtualFiles, languageServiceHost, ts) {
|
|
|
118
118
|
const snapshot = getScriptSnapshot(fileName);
|
|
119
119
|
if (snapshot) {
|
|
120
120
|
extraProjectVersion++;
|
|
121
|
-
const sourceFile = virtualFiles.set(fileName, (0,
|
|
121
|
+
const sourceFile = virtualFiles.set(fileName, (0, language_core_1.resolveCommonLanguageId)(fileName), snapshot);
|
|
122
122
|
if (sourceFile.generated) {
|
|
123
123
|
const text = snapshot.getText(0, snapshot.getLength());
|
|
124
124
|
let patchedText = text.split('\n').map(line => ' '.repeat(line.length)).join('\n');
|
|
@@ -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,13 +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.
|
|
21
|
+
"@volar/language-service": "2.0.2"
|
|
22
22
|
},
|
|
23
|
-
"gitHead": "
|
|
23
|
+
"gitHead": "ae8bccc570e6ee752693b1bfd9e815668b5f32b9"
|
|
24
24
|
}
|