Skip to main content

workspace

Variables

bookmarks

const bookmarks: BookmarkFolder[]

Defined in: modules/workspace/recent.d.ts:39

Retrieves the list of all user-saved bookmarked folders.


name

const name: string | undefined

Defined in: modules/workspace/workspace.d.ts:22

The name of the current workspace/folder. Returns undefined if no workspace is currently active. *

Example

if (mscode.workspace.name) {
console.log("Working inside: ", mscode.workspace.name);
}

recentWorkspaces

const recentWorkspaces: RecentWorkspace[]

Defined in: modules/workspace/recent.d.ts:34

Retrieves the list of all recently opened workspaces. The list is automatically sorted from most recent to oldest. *

Example

const recents = mscode.workspace.recentWorkspaces;
if (recents.length > 0) {
console.log(`Last worked on: ${recents[0].name}`);
}

workspacePath

const workspacePath: string | undefined

Defined in: modules/workspace/workspace.d.ts:33

The absolute file system path of the currently open workspace. Returns undefined if no workspace is currently active. *

Example

const rootPath = mscode.workspace.workspacePath;
if (rootPath) {
const packageJson = `${rootPath}/package.json`;
}

Functions

addBookmark()

addBookmark(name, path): Promise<void>

Defined in: modules/workspace/recent.d.ts:60

Adds a directory path to the user's saved bookmarks. Bookmarks typically appear pinned in the explorer or dashboard. *

Parameters

name

string

The display name of the bookmarked folder.

path

string

The absolute system path to bookmark.

Returns

Promise<void>


addRecentWorkspace()

addRecentWorkspace(name, path): Promise<void>

Defined in: modules/workspace/recent.d.ts:47

Adds a new project or workspace to the recent history tracking. If the path already exists, it is bumped to the top of the list. *

Parameters

name

string

The display name of the project.

path

string

The absolute file system path.

Returns

Promise<void>


clearRecentWorkspaces()

clearRecentWorkspaces(): Promise<void>

Defined in: modules/workspace/recent.d.ts:52

Wipes the entire recent workspace history array from disk storage.

Returns

Promise<void>


getConfiguration()

getConfiguration(section?): WorkspaceConfiguration

Defined in: modules/workspace/configuration.d.ts:95

Accesses configuration settings for a specific section. Allows extensions to read settings customized by the user. *

Parameters

section?

string

The configuration section (e.g., 'editor', 'terminal', 'myExtension').

Returns

WorkspaceConfiguration

A configuration object scoped to the specified section. *

Example

const config = mscode.workspace.getConfiguration('myExtension');
const isEnabled = config.get<boolean>('enableFeature', true);
const maxLimit = config.get<number>('maxLimit', 100);

onDidChangeWorkspace()

onDidChangeWorkspace(handler): Disposable

Defined in: modules/workspace/workspace.d.ts:57

An event that is emitted when a workspace folder is opened or changed. *

Parameters

handler

(folder) => void

A callback function that receives the new workspace data.

Returns

Disposable

A disposable to unregister the event listener. *

Example

const dispose = mscode.workspace.onDidChangeWorkspace((folder) => {
if (folder.path) {
mscode.window.showInformationMessage(`Workspace switched to ${folder.name}`);
}
});

openWorkspace()

openWorkspace(name, path): void

Defined in: modules/workspace/workspace.d.ts:44

Programmatically loads and opens a new workspace folder in the IDE. This will re-initialize the file explorer and set the new context. *

Parameters

name

string

The display name of the workspace.

path

string

The absolute system path to the directory. *

Returns

void

Example

// Automatically open a cloned repository
mscode.workspace.openWorkspace('MyNewApp', '/sdcard/Projects/MyNewApp');

registerConfiguration()

registerConfiguration(schema): Disposable

Defined in: modules/workspace/configuration.d.ts:121

Registers a new configuration schema to the IDE settings UI. Settings registered here automatically appear in the user's Settings Panel. *

Parameters

schema

IConfigurationSection

The configuration schema defining properties and defaults.

Returns

Disposable

A disposable object to safely unregister the settings upon deactivation. *

Example

const dispose = mscode.workspace.registerConfiguration({
id: 'my-linter',
title: 'Awesome Linter Settings',
properties: {
'myLinter.enable': {
type: 'boolean',
default: true,
description: 'Enable or disable the linter globally.'
},
'myLinter.mode': {
type: 'select',
default: 'strict',
enum: ['strict', 'loose'],
description: 'Validation strictness mode.'
}
}
});

removeBookmark()

removeBookmark(path): Promise<void>

Defined in: modules/workspace/recent.d.ts:66

Removes a directory path from the user's saved bookmarks. *

Parameters

path

string

The exact file system path to remove.

Returns

Promise<void>