workspace

Namespace for dealing with the current workspace. A workspace is the collection of one or more folders that are opened in an editor window (instance).

It is also possible to open an editor without a workspace. For example, when you open a new editor window by selecting a file from your platform's File menu, you will not be inside a workspace. In this mode, some of the editor's capabilities are reduced but you can still open text files and edit them.

Refer to https://code.visualstudio.com/docs/editor/workspaces for more information on the concept of workspaces.

The workspace offers support for listening to fs events and for finding files. Both perform well and run outside the editor-process so that they should be always used instead of nodejs-equivalents.

Online Documentation

Properties

Link copied to clipboard

A file system instance that allows to interact with local and remote files, e.g. vscode.workspace.fs.readDirectory(someUri) allows to retrieve all entries of a directory or vscode.workspace.fs.stat(anotherUri) returns the meta data for a file.

Link copied to clipboard

When true, the user has explicitly trusted the contents of the workspace.

Link copied to clipboard
val name: String?

The name of the workspace. undefined when no workspace has been opened.

Link copied to clipboard

All notebook documents currently known to the editor.

Link copied to clipboard

An event that is emitted when the configuration changed.

Link copied to clipboard

An event that is emitted when a notebook has changed.

Link copied to clipboard

An event that is emitted when a text document is changed. This usually happens when the contents changes but also when other things like the dirty-state changes.

Link copied to clipboard

An event that is emitted when a workspace folder is added or removed.

Link copied to clipboard

An event that is emitted when a notebook is disposed.

Link copied to clipboard

An event that is emitted when a text document is disposed or when the language id of a text document has been changed.

Link copied to clipboard

An event that is emitted when files have been created.

Link copied to clipboard

An event that is emitted when files have been deleted.

Link copied to clipboard

Event that fires when the current workspace has been trusted.

Link copied to clipboard

An event that is emitted when a notebook is opened.

Link copied to clipboard

An event that is emitted when a text document is opened or when the language id of a text document has been changed.

Link copied to clipboard

An event that is emitted when files have been renamed.

Link copied to clipboard

An event that is emitted when a notebook is saved.

Link copied to clipboard

An event that is emitted when a text document is saved to disk.

Link copied to clipboard

An event that is emitted when files are being created.

Link copied to clipboard

An event that is emitted when files are being deleted.

Link copied to clipboard

An event that is emitted when files are being renamed.

Link copied to clipboard

An event that is emitted when a notebook document will be saved to disk.

Link copied to clipboard

An event that is emitted when a text document will be saved to disk.

Link copied to clipboard

All text documents currently known to the editor.

Link copied to clipboard

The location of the workspace file, for example:

Link copied to clipboard

List of workspace folders (0-N) that are open in the editor. undefined when no workspace has been opened.

Functions

Link copied to clipboard
fun applyEdit(edit: WorkspaceEdit, metadata: WorkspaceEditMetadata = definedExternally): PromiseLike<JsBoolean>

Make changes to one or many resources or create, delete, and rename resources as defined by the given workspace edit.

Link copied to clipboard
fun asRelativePath(pathOrUri: JsAny, includeWorkspaceFolder: Boolean = definedExternally): String

Returns a path that is relative to the workspace folder or folders.

Link copied to clipboard
fun createFileSystemWatcher(    globPattern: GlobPattern,     ignoreCreateEvents: Boolean = definedExternally,     ignoreChangeEvents: Boolean = definedExternally,     ignoreDeleteEvents: Boolean = definedExternally): FileSystemWatcher

Creates a file system watcher that is notified on file events (create, change, delete) depending on the parameters provided.

Link copied to clipboard

Decodes the content from a Uint8Array to a string. You MUST provide the entire content at once to ensure that the encoding can properly apply. Do not use this method to decode content in chunks, as that may lead to incorrect results.

Link copied to clipboard
fun encode(content: String): PromiseLike<Uint8Array<*>>

Encodes the content of a string to a Uint8Array.

Link copied to clipboard
fun findFiles(    include: GlobPattern,     exclude: GlobPattern? = definedExternally,     maxResults: Int = definedExternally,     token: CancellationToken = definedExternally): PromiseLike<ReadonlyArray<Uri>>

Find files across all workspace folders in the workspace.

Link copied to clipboard
fun getConfiguration(section: String = definedExternally, scope: ConfigurationScope? = definedExternally): WorkspaceConfiguration

Get a workspace configuration object.

Link copied to clipboard

Returns the workspace folder that contains a given uri.

Link copied to clipboard

Open a notebook. Will return early if this notebook is already loaded. Otherwise the notebook is loaded and the {@linkcode onDidOpenNotebookDocument}-event fires.

fun openNotebookDocument(notebookType: String, content: NotebookData = definedExternally): PromiseLike<NotebookDocument>

Open an untitled notebook. The editor will prompt the user for a file path when the document is to be saved.

Link copied to clipboard
fun registerNotebookSerializer(    notebookType: String,     serializer: NotebookSerializer,     options: NotebookDocumentContentOptions = definedExternally): Disposable
Link copied to clipboard

Register a text document content provider.

Link copied to clipboard
fun save(uri: Uri): PromiseLike<Uri?>

Saves the editor identified by the given resource and returns the resulting resource or undefined if save was not successful or no editor with the given resource was found.

Link copied to clipboard
fun saveAll(includeUntitled: Boolean = definedExternally): PromiseLike<JsBoolean>

Save all dirty files.

Link copied to clipboard
fun saveAs(uri: Uri): PromiseLike<Uri?>

Saves the editor identified by the given resource to a new file name as provided by the user and returns the resulting resource or undefined if save was not successful or cancelled or no editor with the given resource was found.