提交 30e065d9 编写于 作者: J Johannes Rieken

debt - remove unused code

上级 d0b77851
......@@ -4,7 +4,6 @@
*--------------------------------------------------------------------------------------------*/
'use strict';
import * as strings from 'vs/base/common/strings';
import {IReadOnlyModel, IPosition} from 'vs/editor/common/editorCommon';
import {ISuggestion} from 'vs/editor/common/modes';
import {Registry} from 'vs/platform/platform';
......@@ -20,8 +19,6 @@ export interface ISnippetsRegistry {
*/
registerSnippets(modeId: string, snippets: ISnippet[], owner?: string): void;
/**
* Visit all snippets
*/
......@@ -63,43 +60,6 @@ class SnippetsRegistry {
}
}
}
public getSnippetCompletions(model: IReadOnlyModel, position: IPosition, result: ISuggestion[]): void {
let modeId = model.getModeId();
if (!this._snippets[modeId]) {
return;
}
let word = model.getWordAtPosition(position);
let currentWord = word ? word.word.substring(0, position.column - word.startColumn).toLowerCase() : '';
let currentFullWord = getNonWhitespacePrefix(model, position).toLowerCase();
this.visitSnippets(modeId, s => {
let overwriteBefore: number;
if (currentWord.length === 0 && currentFullWord.length === 0) {
// if there's no prefix, only show snippets at the beginning of the line, or after a whitespace
overwriteBefore = 0;
} else {
let label = s.prefix.toLowerCase();
// force that the current word or full word matches with the snippet prefix
if (currentWord.length > 0 && strings.startsWith(label, currentWord)) {
overwriteBefore = currentWord.length;
} else if (currentFullWord.length > currentWord.length && strings.startsWith(label, currentFullWord)) {
overwriteBefore = currentFullWord.length;
} else {
return true;
}
}
result.push({
type: 'snippet',
label: s.prefix,
documentation: s.description,
insertText: s.codeSnippet,
noAutoAccept: true,
overwriteBefore
});
return true;
});
}
}
export function getNonWhitespacePrefix(model: IReadOnlyModel, position: IPosition) : string {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册