本文整理汇总了TypeScript中vs/editor/common/editorCommon.ICommonCodeEditor.getModel方法的典型用法代码示例。如果您正苦于以下问题:TypeScript ICommonCodeEditor.getModel方法的具体用法?TypeScript ICommonCodeEditor.getModel怎么用?TypeScript ICommonCodeEditor.getModel使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类vs/editor/common/editorCommon.ICommonCodeEditor
的用法示例。
在下文中一共展示了ICommonCodeEditor.getModel方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: run
public run(accessor: ServicesAccessor, editor: ICommonCodeEditor): TPromise<void> {
const quickOpenService = accessor.get(IQuickOpenService);
if (!editor.getModel()) {
return;
}
const {lineNumber, column} = editor.getPosition();
const modeId = editor.getModel().getModeIdAtPosition(lineNumber, column);
const picks: ISnippetPick[] = [];
Registry.as<ISnippetsRegistry>(Extensions.Snippets).visitSnippets(modeId, snippet => {
picks.push({
label: snippet.prefix,
detail: snippet.description,
snippet
});
return true;
});
return quickOpenService.pick(picks).then(pick => {
if (pick) {
SnippetController.get(editor).insertSnippet(pick.snippet.codeSnippet, 0, 0);
}
});
}
示例2: test
test('Snippet placeholder index incorrect after using 2+ snippets in a row that each end with a placeholder, #30769', function () {
editor.getModel().setValue('');
editor.setSelection(new Selection(1, 1, 1, 1));
const session = new SnippetSession(editor, 'test ${1:replaceme}');
session.insert();
editor.trigger('test', 'type', { text: '1' });
editor.trigger('test', 'type', { text: '\n' });
assert.equal(editor.getModel().getValue(), 'test 1\n');
session.merge('test ${1:replaceme}');
editor.trigger('test', 'type', { text: '2' });
editor.trigger('test', 'type', { text: '\n' });
assert.equal(editor.getModel().getValue(), 'test 1\ntest 2\n');
session.merge('test ${1:replaceme}');
editor.trigger('test', 'type', { text: '3' });
editor.trigger('test', 'type', { text: '\n' });
assert.equal(editor.getModel().getValue(), 'test 1\ntest 2\ntest 3\n');
session.merge('test ${1:replaceme}');
editor.trigger('test', 'type', { text: '4' });
editor.trigger('test', 'type', { text: '\n' });
assert.equal(editor.getModel().getValue(), 'test 1\ntest 2\ntest 3\ntest 4\n');
});
示例3: run
public run(accessor: ServicesAccessor, editor: ICommonCodeEditor): TPromise<void> {
const debugService = accessor.get(IDebugService);
const lineNumber = editor.getPosition().lineNumber;
const modelUri = editor.getModel().uri;
const bp = debugService.getModel().getBreakpoints()
.filter(bp => bp.lineNumber === lineNumber && bp.uri.toString() === modelUri.toString()).pop();
if (bp) {
return debugService.removeBreakpoints(bp.getId());
}
if (debugService.getConfigurationManager().canSetBreakpointsIn(editor.getModel())) {
return debugService.addBreakpoints(modelUri, [{ lineNumber }]);
}
}
示例4: supported
public supported(accessor:ServicesAccessor, editor:ICommonCodeEditor): boolean {
if (!super.supported(accessor, editor)) {
return false;
}
return DocumentSymbolProviderRegistry.has(editor.getModel());
}
示例5: run
public run(accessor: ServicesAccessor, editor: ICommonCodeEditor): void {
let model = editor.getModel();
let commands: ICommand[] = [];
let selections = editor.getSelections();
for (let i = 0; i < selections.length; i++) {
let selection = selections[i];
if (!selection.isEmpty()) {
continue;
}
let lineNumber = selection.startLineNumber;
let column = selection.startColumn;
if (column === 1) {
// at the beginning of line
continue;
}
let maxColumn = model.getLineMaxColumn(lineNumber);
if (column === maxColumn) {
// at the end of line
continue;
}
let lineContent = model.getLineContent(lineNumber);
let charToTheLeft = lineContent.charAt(column - 2);
let charToTheRight = lineContent.charAt(column - 1);
let replaceRange = new Range(lineNumber, column - 1, lineNumber, column + 1);
commands.push(new ReplaceCommand(replaceRange, charToTheRight + charToTheLeft));
}
if (commands.length > 0) {
editor.executeCommands(this.id, commands);
}
}
示例6: run
public run(accessor: ServicesAccessor, editor: ICommonCodeEditor): TPromise<void> {
const debugService = accessor.get(IDebugService);
const viewletService = accessor.get(IViewletService);
const text = editor.getModel().getValueInRange(editor.getSelection());
return viewletService.openViewlet(VIEWLET_ID).then(() => debugService.addWatchExpression(text));
}
示例7: run
public run(accessor: ServicesAccessor, editor: ICommonCodeEditor): void {
let selection = editor.getSelection();
if (selection.isEmpty()) {
return;
}
let model = editor.getModel();
let newSelections = new Array<ISelection>();
let selectionStart = selection.getStartPosition();
let selectionEnd = selection.getEndPosition();
for (var i = selectionStart.lineNumber; i <= selectionEnd.lineNumber; i++) {
if (i !== selectionEnd.lineNumber) {
let currentLineMaxColumn = model.getLineMaxColumn(i);
newSelections.push({
selectionStartLineNumber: i,
selectionStartColumn: currentLineMaxColumn,
positionLineNumber: i,
positionColumn: currentLineMaxColumn
});
} else if (selectionEnd.column > 0) {
newSelections.push({
selectionStartLineNumber: selectionEnd.lineNumber,
selectionStartColumn: selectionEnd.column,
positionLineNumber: selectionEnd.lineNumber,
positionColumn: selectionEnd.column
});
}
}
editor.setSelections(newSelections);
}
示例8: addColumnBreakpoint
function addColumnBreakpoint(accessor: ServicesAccessor, editor: ICommonCodeEditor, remove: boolean): TPromise<any> {
const debugService = accessor.get(IDebugService);
const position = editor.getPosition();
const modelUri = editor.getModel().uri;
const bp = debugService.getModel().getBreakpoints()
.filter(bp => bp.lineNumber === position.lineNumber && bp.column === position.column && bp.uri.toString() === modelUri.toString()).pop();
if (bp) {
return remove ? debugService.removeBreakpoints(bp.getId()) : TPromise.as(null);
}
if (debugService.getConfigurationManager().canSetBreakpointsIn(editor.getModel())) {
return debugService.addBreakpoints(modelUri, [{ lineNumber: position.lineNumber, column: position.column }]);
}
return TPromise.as(null);
}