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


TypeScript ICommonCodeEditor.getSelection方法代码示例

本文整理汇总了TypeScript中vs/editor/common/editorCommon.ICommonCodeEditor.getSelection方法的典型用法代码示例。如果您正苦于以下问题:TypeScript ICommonCodeEditor.getSelection方法的具体用法?TypeScript ICommonCodeEditor.getSelection怎么用?TypeScript ICommonCodeEditor.getSelection使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在vs/editor/common/editorCommon.ICommonCodeEditor的用法示例。


在下文中一共展示了ICommonCodeEditor.getSelection方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: 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

示例2: assertFindState

	function assertFindState(editor: ICommonCodeEditor, cursor: number[], highlighted: number[], findDecorations: number[][]): void {
		assert.deepEqual(fromRange(editor.getSelection()), cursor, 'cursor');

		let expectedState = {
			highlighted: highlighted ? [highlighted] : [],
			findDecorations: findDecorations
		};
		assert.deepEqual(_getFindState(editor), expectedState, 'state');
	}
开发者ID:diarmaidm,项目名称:vscode,代码行数:9,代码来源:findModel.test.ts

示例3: _tmCurrentLine

	private _tmCurrentLine(): string {
		const { positionLineNumber } = this._editor.getSelection();
		return this._editor.getModel().getValueInRange({ startLineNumber: positionLineNumber, startColumn: 1, endLineNumber: positionLineNumber, endColumn: Number.MAX_VALUE });
	}
开发者ID:hungys,项目名称:vscode,代码行数:4,代码来源:snippetVariables.ts

示例4: _tmLineNumber

	private _tmLineNumber(): string {
		return String(this._editor.getSelection().positionLineNumber);
	}
开发者ID:hungys,项目名称:vscode,代码行数:3,代码来源:snippetVariables.ts


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