diff --git a/src/vs/editor/browser/standalone/standaloneLanguages.ts b/src/vs/editor/browser/standalone/standaloneLanguages.ts index 701e3ce33a495e41250562f658e35c6754b4419b..43dfe9ff3531a68c3a861290d53b41dabc4cb148 100644 --- a/src/vs/editor/browser/standalone/standaloneLanguages.ts +++ b/src/vs/editor/browser/standalone/standaloneLanguages.ts @@ -386,10 +386,10 @@ class SuggestAdapter { return { _actual: item, label: item.label, - codeSnippet: item.insertText || item.label, + insertText: item.insertText || item.label, type: convertKind(item.kind), - typeLabel: item.detail, - documentationLabel: item.documentation, + detail: item.detail, + documentation: item.documentation, sortText: item.sortText, filterText: item.filterText }; @@ -444,7 +444,7 @@ class SuggestAdapter { // insert the text of the edit and create a dedicated // suggestion-container with overwrite[Before|After] - suggestion.codeSnippet = item.textEdit.text; + suggestion.insertText = item.textEdit.text; suggestion.overwriteBefore = position.column - editRange.startColumn; suggestion.overwriteAfter = editRange.endColumn - position.column; } else { diff --git a/src/vs/editor/common/modes.ts b/src/vs/editor/common/modes.ts index e81b5419525af60dfc17d7d57984f4b7bfa1e073..1cef590a0809ed1bfb4e1a5859e8a199a9479a80 100644 --- a/src/vs/editor/common/modes.ts +++ b/src/vs/editor/common/modes.ts @@ -358,10 +358,10 @@ export type SuggestionType = 'method' */ export interface ISuggestion { label: string; - codeSnippet: string; + insertText: string; type: SuggestionType; - typeLabel?: string; - documentationLabel?: string; + detail?: string; + documentation?: string; filterText?: string; sortText?: string; noAutoAccept?: boolean; diff --git a/src/vs/editor/common/modes/snippetsRegistry.ts b/src/vs/editor/common/modes/snippetsRegistry.ts index 8ff8275b7919c5bc190db5bd656742d645863dfb..f88ccf926ebb1d7cf9f2b386bcd3ecf7a47e5af2 100644 --- a/src/vs/editor/common/modes/snippetsRegistry.ts +++ b/src/vs/editor/common/modes/snippetsRegistry.ts @@ -92,8 +92,8 @@ class SnippetsRegistry { result.push({ type: 'snippet', label: s.prefix, - documentationLabel: s.description, - codeSnippet: s.codeSnippet, + documentation: s.description, + insertText: s.codeSnippet, noAutoAccept: true, overwriteBefore }); diff --git a/src/vs/editor/common/services/editorSimpleWorker.ts b/src/vs/editor/common/services/editorSimpleWorker.ts index 24c4421ce64bdde018a3926a49b786bf35aed434..642fabd7dc0368be7be6f38913d2e8587e2a9821 100644 --- a/src/vs/editor/common/services/editorSimpleWorker.ts +++ b/src/vs/editor/common/services/editorSimpleWorker.ts @@ -264,7 +264,7 @@ export abstract class BaseEditorSimpleWorker { return { type: 'text', label: word, - codeSnippet: word, + insertText: word, noAutoAccept: true }; }); diff --git a/src/vs/editor/contrib/suggest/browser/suggestWidget.ts b/src/vs/editor/contrib/suggest/browser/suggestWidget.ts index 3472e680d319cec50883650ee2d698168b9b319e..852926035f8fd7a6e51bcdac8322cc9340248aad 100644 --- a/src/vs/editor/contrib/suggest/browser/suggestWidget.ts +++ b/src/vs/editor/contrib/suggest/browser/suggestWidget.ts @@ -99,7 +99,7 @@ class Renderer implements IRenderer { const data = templateData; const suggestion = (element).suggestion; - if (suggestion.documentationLabel) { + if (suggestion.documentation) { data.root.setAttribute('aria-label', nls.localize('suggestionWithDetailsAriaLabel', "{0}, suggestion, has details", suggestion.label)); } else { data.root.setAttribute('aria-label', nls.localize('suggestionAriaLabel', "{0}, suggestion", suggestion.label)); @@ -109,7 +109,7 @@ class Renderer implements IRenderer { data.colorspan.style.backgroundColor = ''; if (suggestion.type === 'color') { - let color = matchesColor(suggestion.label) || matchesColor(suggestion.documentationLabel); + let color = matchesColor(suggestion.label) || matchesColor(suggestion.documentation); if (color) { data.icon.className = 'icon customcolor'; data.colorspan.style.backgroundColor = color; @@ -117,10 +117,10 @@ class Renderer implements IRenderer { } data.highlightedLabel.set(suggestion.label, (element).highlights); - data.typeLabel.textContent = suggestion.typeLabel || ''; - data.documentation.textContent = suggestion.documentationLabel || ''; + data.typeLabel.textContent = suggestion.detail || ''; + data.documentation.textContent = suggestion.documentation || ''; - if (suggestion.documentationLabel) { + if (suggestion.documentation) { show(data.documentationDetails); data.documentationDetails.onmousedown = e => { e.stopPropagation(); @@ -154,7 +154,7 @@ class Delegate implements IDelegate { getHeight(element: CompletionItem): number { const focus = this.listProvider().getFocusedElements()[0]; - if (element.suggestion.documentationLabel && element === focus) { + if (element.suggestion.documentation && element === focus) { return FocusHeight; } @@ -251,8 +251,8 @@ class SuggestionDetails { } this.title.innerText = item.suggestion.label; - this.type.innerText = item.suggestion.typeLabel || ''; - this.docs.innerText = item.suggestion.documentationLabel; + this.type.innerText = item.suggestion.detail || ''; + this.docs.innerText = item.suggestion.documentation; this.back.onmousedown = e => { e.preventDefault(); e.stopPropagation(); @@ -265,7 +265,7 @@ class SuggestionDetails { this.scrollbar.scanDomNode(); - this.ariaLabel = strings.format('{0}\n{1}\n{2}', item.suggestion.label || '', item.suggestion.typeLabel || '', item.suggestion.documentationLabel || ''); + this.ariaLabel = strings.format('{0}\n{1}\n{2}', item.suggestion.label || '', item.suggestion.detail || '', item.suggestion.documentation || ''); } getAriaLabel(): string { @@ -421,7 +421,7 @@ export class SuggestWidget implements IContentWidget, IDisposable { } private _getSuggestionAriaAlertLabel(item:CompletionItem): string { - if (item.suggestion.documentationLabel) { + if (item.suggestion.documentation) { return nls.localize('ariaCurrentSuggestionWithDetails',"{0}, suggestion, has details", item.suggestion.label); } else { return nls.localize('ariaCurrentSuggestion',"{0}, suggestion", item.suggestion.label); @@ -721,7 +721,7 @@ export class SuggestWidget implements IContentWidget, IDisposable { const item = this.list.getFocusedElements()[0]; - if (!item || !item.suggestion.documentationLabel) { + if (!item || !item.suggestion.documentation) { return; } diff --git a/src/vs/editor/contrib/suggest/common/suggestModel.ts b/src/vs/editor/contrib/suggest/common/suggestModel.ts index 19ddaaa1720dbc9d013727ad75d11d4dbc5e28c6..6ec8bcfd502184ea195a633716b9f57e346b20cc 100644 --- a/src/vs/editor/contrib/suggest/common/suggestModel.ts +++ b/src/vs/editor/contrib/suggest/common/suggestModel.ts @@ -380,7 +380,7 @@ export class SuggestModel implements IDisposable { } this._onDidAccept.fire({ - snippet: new CodeSnippet(suggestion.codeSnippet), + snippet: new CodeSnippet(suggestion.insertText), overwriteBefore: overwriteBefore + (this.editor.getPosition().column - this.context.column), overwriteAfter }); diff --git a/src/vs/editor/contrib/suggest/test/common/suggest.test.ts b/src/vs/editor/contrib/suggest/test/common/suggest.test.ts index 9078e2136b0685d8eda77e684568ded1ea8906ff..dfb53d6017bc417a94e7a80dae82a23f3282d2dc 100644 --- a/src/vs/editor/contrib/suggest/test/common/suggest.test.ts +++ b/src/vs/editor/contrib/suggest/test/common/suggest.test.ts @@ -30,15 +30,15 @@ suite('Suggest', function () { suggestions: [{ label: 'aaa', type: 'snippet', - codeSnippet: 'aaa' + insertText: 'aaa' }, { label: 'zzz', type: 'snippet', - codeSnippet: 'zzz' + insertText: 'zzz' }, { label: 'fff', type: 'property', - codeSnippet: 'fff' + insertText: 'fff' }] }; } diff --git a/src/vs/languages/html/common/htmlWorker.ts b/src/vs/languages/html/common/htmlWorker.ts index 533f64ebb9a0957fa21c6dba0fc6debb6bb94cf6..1c74011d77b2508d84d65cf2e0d863c1c1505261 100644 --- a/src/vs/languages/html/common/htmlWorker.ts +++ b/src/vs/languages/html/common/htmlWorker.ts @@ -146,7 +146,7 @@ export class HTMLWorker { if (matchingTag) { let suggestion : modes.ISuggestion = { label: '/' + matchingTag, - codeSnippet: '/' + matchingTag + closeTag, + insertText: '/' + matchingTag + closeTag, overwriteBefore: overwriteBefore, type: 'property' }; @@ -159,7 +159,7 @@ export class HTMLWorker { let endIndent = model.getLineContent(endPosition.lineNumber).substring(0, endPosition.column - 1); if (isWhiteSpace(startIndent) && isWhiteSpace(endIndent)) { suggestion.overwriteBefore = position.column - 1; // replace from start of line - suggestion.codeSnippet = startIndent + ' { suggestions.suggestions.push({ label: tag, - codeSnippet: tag, + insertText: tag, type: 'property', - documentationLabel: label, + documentation: label, overwriteBefore: suggestions.currentWord.length }); }); @@ -227,7 +227,7 @@ export class HTMLWorker { } suggestions.suggestions.push({ label: attribute, - codeSnippet: codeSnippet, + insertText: codeSnippet, type: type === 'handler' ? 'function' : 'value', overwriteBefore: suggestions.currentWord.length }); @@ -260,7 +260,7 @@ export class HTMLWorker { provider.collectValues(parentTag, attribute,(value) => { suggestions.suggestions.push({ label: value, - codeSnippet: needsQuotes ? '"' + value + '"' : value, + insertText: needsQuotes ? '"' + value + '"' : value, type: 'unit', overwriteBefore: suggestions.currentWord.length }); diff --git a/src/vs/languages/html/test/common/html-worker.test.ts b/src/vs/languages/html/test/common/html-worker.test.ts index 3e41c51bd7ed4b0b891b68dbf6bb7a5ca2adc103..5f805a88bfbf6585cdf52b02962fc43be0b8678a 100644 --- a/src/vs/languages/html/test/common/html-worker.test.ts +++ b/src/vs/languages/html/test/common/html-worker.test.ts @@ -54,7 +54,7 @@ suite('HTML - worker', () => { var assertSuggestion = function(completion: Modes.ISuggestResult, label: string, type?: string, codeSnippet?: string) { var proposalsFound = completion.suggestions.filter(function(suggestion: Modes.ISuggestion) { - return suggestion.label === label && (!type || suggestion.type === type) && (!codeSnippet || suggestion.codeSnippet === codeSnippet); + return suggestion.label === label && (!type || suggestion.type === type) && (!codeSnippet || suggestion.insertText === codeSnippet); }); if (proposalsFound.length !== 1) { assert.fail('Suggestion not found: ' + label + ', has ' + completion.suggestions.map(s => s.label).join(', ')); diff --git a/src/vs/workbench/api/node/extHostLanguageFeatures.ts b/src/vs/workbench/api/node/extHostLanguageFeatures.ts index b8c6937dec739d325d5bc2c42c90f84cab92cbf8..0756681e9ee44ba76e871499dbe5edf2018051e2 100644 --- a/src/vs/workbench/api/node/extHostLanguageFeatures.ts +++ b/src/vs/workbench/api/node/extHostLanguageFeatures.ts @@ -554,7 +554,7 @@ class SuggestAdapter { // insert the text of the edit and create a dedicated // suggestion-container with overwrite[Before|After] - suggestion.codeSnippet = item.textEdit.newText; + suggestion.insertText = item.textEdit.newText; suggestion.overwriteBefore = pos.character - editRange.start.character; suggestion.overwriteAfter = editRange.end.character - pos.character; diff --git a/src/vs/workbench/api/node/extHostTypeConverters.ts b/src/vs/workbench/api/node/extHostTypeConverters.ts index 53511be0c674fab0cf6be0dc8dee87cef46913bf..692f8411432b402a0ae81751d11bf9a34526929b 100644 --- a/src/vs/workbench/api/node/extHostTypeConverters.ts +++ b/src/vs/workbench/api/node/extHostTypeConverters.ts @@ -314,10 +314,10 @@ export const Suggest = { from(item: vscode.CompletionItem): modes.ISuggestion { const suggestion: modes.ISuggestion = { label: item.label, - codeSnippet: item.insertText || item.label, + insertText: item.insertText || item.label, type: CompletionItemKind.from(item.kind), - typeLabel: item.detail, - documentationLabel: item.documentation, + detail: item.detail, + documentation: item.documentation, sortText: item.sortText, filterText: item.filterText }; @@ -326,10 +326,10 @@ export const Suggest = { to(container: modes.ISuggestResult, position: types.Position, suggestion: modes.ISuggestion): types.CompletionItem { const result = new types.CompletionItem(suggestion.label); - result.insertText = suggestion.codeSnippet; + result.insertText = suggestion.insertText; result.kind = CompletionItemKind.to(suggestion.type); - result.detail = suggestion.typeLabel; - result.documentation = suggestion.documentationLabel; + result.detail = suggestion.detail; + result.documentation = suggestion.documentation; result.sortText = suggestion.sortText; result.filterText = suggestion.filterText; @@ -340,7 +340,7 @@ export const Suggest = { endPosition = new types.Position(position.line, position.character + suggestion.overwriteAfter); } - result.textEdit = types.TextEdit.replace(new types.Range(startPosition, endPosition), suggestion.codeSnippet); + result.textEdit = types.TextEdit.replace(new types.Range(startPosition, endPosition), suggestion.insertText); return result; } }; diff --git a/src/vs/workbench/test/node/api/extHostLanguageFeatures.test.ts b/src/vs/workbench/test/node/api/extHostLanguageFeatures.test.ts index 0bb74914e8bfba239cf57d15664b378bc36f83e1..624de04ca5df3039bf64bdbb186f2f644bd9fc15 100644 --- a/src/vs/workbench/test/node/api/extHostLanguageFeatures.test.ts +++ b/src/vs/workbench/test/node/api/extHostLanguageFeatures.test.ts @@ -767,7 +767,7 @@ suite('ExtHostLanguageFeatures', function() { return threadService.sync().then(() => { return provideSuggestionItems(model, new EditorPosition(1, 1), { snippetConfig: 'none' }).then(value => { assert.equal(value.length, 1); - assert.equal(value[0].suggestion.codeSnippet, 'testing2'); + assert.equal(value[0].suggestion.insertText, 'testing2'); }); }); }); @@ -789,7 +789,7 @@ suite('ExtHostLanguageFeatures', function() { return threadService.sync().then(() => { return provideSuggestionItems(model, new EditorPosition(1, 1), { snippetConfig: 'none' }).then(value => { assert.equal(value.length, 1); - assert.equal(value[0].suggestion.codeSnippet, 'weak-selector'); + assert.equal(value[0].suggestion.insertText, 'weak-selector'); }); }); }); @@ -811,8 +811,8 @@ suite('ExtHostLanguageFeatures', function() { return threadService.sync().then(() => { return provideSuggestionItems(model, new EditorPosition(1, 1), { snippetConfig: 'none' }).then(value => { assert.equal(value.length, 2); - assert.equal(value[0].suggestion.codeSnippet, 'strong-1'); // sort by label - assert.equal(value[1].suggestion.codeSnippet, 'strong-2'); + assert.equal(value[0].suggestion.insertText, 'strong-1'); // sort by label + assert.equal(value[1].suggestion.insertText, 'strong-2'); }); }); });