当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript ICommonCodeEditor.getModel方法代码示例

本文整理汇总了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);
			}
		});
	}
开发者ID:sandy081,项目名称:vscode,代码行数:26,代码来源:snippetCompletion.ts

示例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');
	});
开发者ID:gokulakrishna9,项目名称:vscode,代码行数:28,代码来源:snippetSession.test.ts

示例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 }]);
		}
	}
开发者ID:sandy081,项目名称:vscode,代码行数:15,代码来源:debugEditorActions.ts

示例4: supported

	public supported(accessor:ServicesAccessor, editor:ICommonCodeEditor): boolean {
		if (!super.supported(accessor, editor)) {
			return false;
		}

		return DocumentSymbolProviderRegistry.has(editor.getModel());
	}
开发者ID:aarondandy,项目名称:vscode,代码行数:7,代码来源:quickOutline.ts

示例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);
		}
	}
开发者ID:hungys,项目名称:vscode,代码行数:35,代码来源:transpose.ts

示例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));
	}
开发者ID:diarmaidm,项目名称:vscode,代码行数:7,代码来源:debugEditorActions.ts

示例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);
	}
开发者ID:StateFarmIns,项目名称:vscode,代码行数:30,代码来源:multicursor.ts

示例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);
}
开发者ID:yuit,项目名称:vscode,代码行数:17,代码来源:debugEditorActions.ts


注:本文中的vs/editor/common/editorCommon.ICommonCodeEditor.getModel方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。