debt - remove unused code
This commit is contained in:
parent
d0b77851a5
commit
30e065d90d
|
@ -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 {
|
||||
|
|
Loading…
Reference in a new issue