我通讀了 API 檔案并了解如何獲取值,但無法很好地設定值。
例如,我想更改活動行(游標行),因此嘗試更新editor.selection.active如下值。
// get the current value
editor.selection.active
V {_line: 12, _character: 0}
// I tried to update the value
editor.selection.active.line = 3
3
// I was expecting this an updated value but unchanged
editor.selection.active
V {_line: 12, _character: 0}
但正如上面的評論,它不會更新值,不會更改活動行位置。那么我該怎么做呢?謝謝。
uj5u.com熱心網友回復:
您必須editor.selections使用新選擇更新屬性:
const newStartPosition = new vscode.Position(3, 0);
const newEndPosition = new vscode.Position(yourLine, yourCharacter);
const newSelections = [new vscode.Selection(newStartPosition, newEndPosition )];
editor.selections = newSelections;
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/399824.html
