mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-27 12:04:04 +01:00
make NotebookEditor#selections writeable, https://github.com/microsoft/vscode/issues/125275
This commit is contained in:
@@ -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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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>
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user