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.
Properties
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.
All notebook documents currently known to the editor.
An event that is emitted when the configuration changed.
An event that is emitted when a notebook has changed.
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.
An event that is emitted when a workspace folder is added or removed.
An event that is emitted when a notebook is disposed.
An event that is emitted when a text document is disposed or when the language id of a text document has been changed.
An event that is emitted when files have been created.
An event that is emitted when files have been deleted.
Event that fires when the current workspace has been trusted.
An event that is emitted when a notebook is opened.
An event that is emitted when a text document is opened or when the language id of a text document has been changed.
An event that is emitted when files have been renamed.
An event that is emitted when a notebook is saved.
An event that is emitted when a text document is saved to disk.
An event that is emitted when files are being created.
An event that is emitted when files are being deleted.
An event that is emitted when files are being renamed.
An event that is emitted when a notebook document will be saved to disk.
An event that is emitted when a text document will be saved to disk.
All text documents currently known to the editor.
The location of the workspace file, for example:
List of workspace folders (0-N) that are open in the editor. undefined
when no workspace has been opened.
Functions
Make changes to one or many resources or create, delete, and rename resources as defined by the given workspace edit.
Returns a path that is relative to the workspace folder or folders.
Creates a file system watcher that is notified on file events (create, change, delete) depending on the parameters provided.
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.
Encodes the content of a string
to a Uint8Array
.
Find files across all workspace folders in the workspace.
Get a workspace configuration object.
Returns the workspace folder that contains a given uri.
Open a notebook. Will return early if this notebook is already loaded. Otherwise the notebook is loaded and the {@linkcode onDidOpenNotebookDocument}-event fires.
Open an untitled notebook. The editor will prompt the user for a file path when the document is to be saved.
Register a notebook serializer.
Register a text document content provider.
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.
Save all dirty files.
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.