make NotebookEditor#selections writeable, https://github.com/microsoft/vscode/issues/125275

This commit is contained in:
Johannes Rieken
2021-06-07 17:07:46 +02:00
parent cec19dcfdc
commit 76fe0c90b0
4 changed files with 22 additions and 1 deletions

View File

@@ -186,4 +186,12 @@ export class MainThreadNotebookEditors implements MainThreadNotebookEditorsShape
notebookEditor.setEditorDecorations(key, range);
}
}
$trySetSelections(id: string, ranges: ICellRange[]): void {
const editor = this._notebookEditorService.getNotebookEditor(id);
if (editor) {
// @rebornix how to set an editor selection?
// editor.setSelections(ranges)
}
}
}

View File

@@ -894,6 +894,7 @@ export interface MainThreadNotebookEditorsShape extends IDisposable {
$tryRevealRange(id: string, range: ICellRange, revealType: NotebookEditorRevealType): Promise<void>;
$registerNotebookEditorDecorationType(key: string, options: INotebookDecorationRenderOptions): void;
$removeNotebookEditorDecorationType(key: string): void;
$trySetSelections(id: string, range: ICellRange[]): void;
$trySetDecorations(id: string, range: ICellRange, decorationKey: string): void;
$tryApplyEdits(editorId: string, modelVersionId: number, cellEdits: ICellEditOperation[]): Promise<boolean>
}

View File

@@ -9,6 +9,7 @@ import * as extHostConverter from 'vs/workbench/api/common/extHostTypeConverters
import { CellEditType, ICellEditOperation, ICellReplaceEdit } from 'vs/workbench/contrib/notebook/common/notebookCommon';
import * as vscode from 'vscode';
import { ExtHostNotebookDocument } from './extHostNotebookDocument';
import { illegalArgument } from 'vs/base/common/errors';
interface INotebookEditData {
documentVersionId: number;
@@ -107,6 +108,13 @@ export class ExtHostNotebookEditor {
get selections() {
return that._selections;
},
set selections(value: vscode.NotebookRange[]) {
if (!Array.isArray(value) || !value.every(extHostTypes.NotebookRange.isNotebookRange)) {
throw illegalArgument('selections');
}
that._selections = value;
that._trySetSelections(value);
},
get visibleRanges() {
return that._visibleRanges;
},
@@ -151,6 +159,10 @@ export class ExtHostNotebookEditor {
this._selections = selections;
}
private _trySetSelections(value: vscode.NotebookRange[]): void {
this._proxy.$trySetSelections(this.id, value.map(extHostConverter.NotebookRange.from));
}
_acceptViewColumn(value: vscode.ViewColumn | undefined) {
this._viewColumn = value;
}