typescript-language-server
Advanced tools
Comparing version 0.11.0 to 0.11.1
# Changelog | ||
All notable changes to this project will be documented in this file. | ||
## [0.11.1](https://github.com/typescript-language-server/typescript-language-server/compare/v0.11.0...v0.11.1) (2022-06-13) | ||
### Bug Fixes | ||
* completion for strings with trigger character ([#492](https://github.com/typescript-language-server/typescript-language-server/issues/492)) ([76bf9a4](https://github.com/typescript-language-server/typescript-language-server/commit/76bf9a4817ffa1e340422cfd5177dbcb96528ddb)) | ||
## [0.11.0](https://github.com/typescript-language-server/typescript-language-server/compare/v0.10.1...v0.11.0) (2022-06-06) | ||
@@ -5,0 +12,0 @@ |
@@ -12,3 +12,4 @@ import * as lsp from 'vscode-languageserver/node'; | ||
export declare function isValidFunctionCompletionContext(filepath: string, position: lsp.Position, client: TspClient): Promise<boolean>; | ||
export declare function getCompletionTriggerCharacter(character: string | undefined): tsp.CompletionsTriggerCharacter | undefined; | ||
export {}; | ||
//# sourceMappingURL=completion.d.ts.map |
@@ -44,3 +44,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.isValidFunctionCompletionContext = exports.asResolvedCompletionItem = exports.asCompletionItem = void 0; | ||
exports.getCompletionTriggerCharacter = exports.isValidFunctionCompletionContext = exports.asResolvedCompletionItem = exports.asCompletionItem = void 0; | ||
const lsp = __importStar(require("vscode-languageserver/node")); | ||
@@ -125,3 +125,6 @@ const tsp_command_types_1 = require("./tsp-command-types"); | ||
} | ||
if (insertText && replacementRange) { | ||
if (replacementRange) { | ||
if (!insertText) { | ||
insertText = item.label; | ||
} | ||
item.textEdit = lsp.TextEdit.replace(replacementRange, insertText); | ||
@@ -393,2 +396,19 @@ } | ||
} | ||
function getCompletionTriggerCharacter(character) { | ||
switch (character) { | ||
case '@': | ||
case '#': | ||
case ' ': | ||
case '.': | ||
case '"': | ||
case '\'': | ||
case '`': | ||
case '/': | ||
case '<': | ||
return character; | ||
default: | ||
return undefined; | ||
} | ||
} | ||
exports.getCompletionTriggerCharacter = getCompletionTriggerCharacter; | ||
//# sourceMappingURL=completion.js.map |
@@ -560,7 +560,12 @@ "use strict"; | ||
try { | ||
const result = yield this.interuptDiagnostics(() => this.tspClient.request("completionInfo" /* CompletionInfo */, { | ||
file, | ||
line: params.position.line + 1, | ||
offset: params.position.character + 1 | ||
})); | ||
const result = yield this.interuptDiagnostics(() => { | ||
var _a, _b; | ||
return this.tspClient.request("completionInfo" /* CompletionInfo */, { | ||
file, | ||
line: params.position.line + 1, | ||
offset: params.position.character + 1, | ||
triggerCharacter: (0, completion_1.getCompletionTriggerCharacter)((_a = params.context) === null || _a === void 0 ? void 0 : _a.triggerCharacter), | ||
triggerKind: (_b = params.context) === null || _b === void 0 ? void 0 : _b.triggerKind | ||
}); | ||
}); | ||
const { body } = result; | ||
@@ -567,0 +572,0 @@ const completions = (body ? body.entries : []) |
@@ -338,2 +338,35 @@ "use strict"; | ||
})).timeout(10000); | ||
it('includes textEdit for string completion', () => __awaiter(void 0, void 0, void 0, function* () { | ||
const doc = { | ||
uri: (0, test_utils_1.uri)('bar.ts'), | ||
languageId: 'typescript', | ||
version: 1, | ||
text: ` | ||
function test(value: "fs/read" | "hello/world") { | ||
return true; | ||
} | ||
test("fs/") | ||
` | ||
}; | ||
server.didOpenTextDocument({ textDocument: doc }); | ||
const proposals = yield server.completion({ | ||
textDocument: doc, | ||
position: (0, test_utils_1.positionAfter)(doc, 'test("fs/'), | ||
context: { | ||
triggerCharacter: '/', | ||
triggerKind: 2 | ||
} | ||
}); | ||
assert.isNotNull(proposals); | ||
const completion = proposals.items.find(completion => completion.label === 'fs/read'); | ||
assert.strictEqual(completion.label, 'fs/read'); | ||
assert.deepStrictEqual(completion.textEdit, { | ||
range: { | ||
start: { line: 5, character: 20 }, | ||
end: { line: 5, character: 23 } | ||
}, | ||
newText: 'fs/read' | ||
}); | ||
})).timeout(10000); | ||
}); | ||
@@ -340,0 +373,0 @@ describe('diagnostics', () => { |
{ | ||
"name": "typescript-language-server", | ||
"version": "0.11.0", | ||
"version": "0.11.1", | ||
"description": "Language Server Protocol (LSP) implementation for TypeScript using tsserver", | ||
@@ -5,0 +5,0 @@ "author": "TypeFox and others", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
572948
7420