當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。