Skip to content

EditorView

Jan Richter edited this page Mar 24, 2020 · 10 revisions

editorView

Lookup

import { EditorView } from 'vscode-extension-tester';
...
const editorView = new EditorView();

Select an Editor Tab

// open editor tab by title
const editor = await editorView.openEditor('package.json');

Closing Editors

// close an editor tab by title
await editorView.closeEditor('package.json');
// close all open tabs
await editorView.closeAllEditors();

Retrieve Open Tab Titles

const titles = await editorView.getOpenEditorTitles();

Editor Groups

By default, all EditorView methods work with the first (left-most) editor group, except closeAllEditors and getOpenEditorTitles which by default work across all groups. You can use indices to target specific editor groups, or you can get handles to directly work with EditorGroup objects.

EditorView Actions on Editor Groups

// open editor in the second group (from the left, using a zero-based index)
const editor = await editorView.openEditor('package.json', 1);


// close editor in the second group
await editorView.closeEditor('package.json', 1);

// close all editors in the second group (and the whole group)
await editorView.closeAllEditors(1);

// get open editor titles for the second group
const titles = await editorView.getOpenEditorTitles(1);

Retrieve Handles for the Editor Groups

Instead of working in context of the whole editor view, you can get a handle for a particular editor group. The EditorGroup object then exposes the same set of methods as EditorView (without the group retrieval though).

// get the handle for the second group
const group = await editorView.getEditorGroup(1);

// get handles for all editor groups in an array
const groups = await editorView.getEditorGroups();
Clone this wiki locally