本文整理汇总了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);
}
示例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');
}
示例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 });
}
示例4: _tmLineNumber
private _tmLineNumber(): string {
return String(this._editor.getSelection().positionLineNumber);
}