mirror of
https://github.com/coder/code-server.git
synced 2026-05-06 04:25:19 +02:00
chore(vscode): update to 1.54.2
This commit is contained in:
@@ -8,13 +8,13 @@ import { coalesce } from 'vs/base/common/arrays';
|
||||
import { IStateService } from 'vs/platform/state/node/state';
|
||||
import { app, JumpListCategory, JumpListItem } from 'electron';
|
||||
import { ILogService } from 'vs/platform/log/common/log';
|
||||
import { getBaseLabel, getPathLabel, splitName } from 'vs/base/common/labels';
|
||||
import { normalizeDriveLetter, splitName } from 'vs/base/common/labels';
|
||||
import { Event as CommonEvent, Emitter } from 'vs/base/common/event';
|
||||
import { isWindows, isMacintosh } from 'vs/base/common/platform';
|
||||
import { IWorkspaceIdentifier, IRecentlyOpened, isRecentWorkspace, isRecentFolder, IRecent, isRecentFile, IRecentFolder, IRecentWorkspace, IRecentFile, toStoreData, restoreRecentlyOpened, RecentlyOpenedStorageData, WORKSPACE_EXTENSION, isWorkspaceIdentifier, isSingleFolderWorkspaceIdentifier } from 'vs/platform/workspaces/common/workspaces';
|
||||
import { IWorkspacesManagementMainService } from 'vs/platform/workspaces/electron-main/workspacesManagementMainService';
|
||||
import { ThrottledDelayer } from 'vs/base/common/async';
|
||||
import { dirname, originalFSPath, basename, extUriBiasedIgnorePathCase } from 'vs/base/common/resources';
|
||||
import { originalFSPath, basename, extUriBiasedIgnorePathCase } from 'vs/base/common/resources';
|
||||
import { URI } from 'vs/base/common/uri';
|
||||
import { Schemas } from 'vs/base/common/network';
|
||||
import { IEnvironmentMainService } from 'vs/platform/environment/electron-main/environmentMainService';
|
||||
@@ -30,7 +30,7 @@ export interface IWorkspacesHistoryMainService {
|
||||
|
||||
readonly _serviceBrand: undefined;
|
||||
|
||||
readonly onRecentlyOpenedChange: CommonEvent<void>;
|
||||
readonly onDidChangeRecentlyOpened: CommonEvent<void>;
|
||||
|
||||
addRecentlyOpened(recents: IRecent[]): void;
|
||||
getRecentlyOpened(include?: ICodeWindow): IRecentlyOpened;
|
||||
@@ -57,8 +57,8 @@ export class WorkspacesHistoryMainService extends Disposable implements IWorkspa
|
||||
|
||||
declare readonly _serviceBrand: undefined;
|
||||
|
||||
private readonly _onRecentlyOpenedChange = this._register(new Emitter<void>());
|
||||
readonly onRecentlyOpenedChange: CommonEvent<void> = this._onRecentlyOpenedChange.event;
|
||||
private readonly _onDidChangeRecentlyOpened = this._register(new Emitter<void>());
|
||||
readonly onDidChangeRecentlyOpened: CommonEvent<void> = this._onDidChangeRecentlyOpened.event;
|
||||
|
||||
private readonly macOSRecentDocumentsUpdater = this._register(new ThrottledDelayer<void>(800));
|
||||
|
||||
@@ -66,7 +66,7 @@ export class WorkspacesHistoryMainService extends Disposable implements IWorkspa
|
||||
@IStateService private readonly stateService: IStateService,
|
||||
@ILogService private readonly logService: ILogService,
|
||||
@IWorkspacesManagementMainService private readonly workspacesManagementMainService: IWorkspacesManagementMainService,
|
||||
@IEnvironmentMainService private readonly environmentService: IEnvironmentMainService,
|
||||
@IEnvironmentMainService private readonly environmentMainService: IEnvironmentMainService,
|
||||
@ILifecycleMainService private readonly lifecycleMainService: ILifecycleMainService
|
||||
) {
|
||||
super();
|
||||
@@ -80,7 +80,7 @@ export class WorkspacesHistoryMainService extends Disposable implements IWorkspa
|
||||
this.lifecycleMainService.when(LifecycleMainPhase.AfterWindowOpen).then(() => this.handleWindowsJumpList());
|
||||
|
||||
// Add to history when entering workspace
|
||||
this._register(this.workspacesManagementMainService.onWorkspaceEntered(event => this.addRecentlyOpened([{ workspace: event.workspace }])));
|
||||
this._register(this.workspacesManagementMainService.onDidEnterWorkspace(event => this.addRecentlyOpened([{ workspace: event.workspace }])));
|
||||
}
|
||||
|
||||
private handleWindowsJumpList(): void {
|
||||
@@ -89,7 +89,7 @@ export class WorkspacesHistoryMainService extends Disposable implements IWorkspa
|
||||
}
|
||||
|
||||
this.updateWindowsJumpList();
|
||||
this._register(this.onRecentlyOpenedChange(() => this.updateWindowsJumpList()));
|
||||
this._register(this.onDidChangeRecentlyOpened(() => this.updateWindowsJumpList()));
|
||||
}
|
||||
|
||||
addRecentlyOpened(recentToAdd: IRecent[]): void {
|
||||
@@ -139,7 +139,7 @@ export class WorkspacesHistoryMainService extends Disposable implements IWorkspa
|
||||
}
|
||||
|
||||
this.saveRecentlyOpened({ workspaces, files });
|
||||
this._onRecentlyOpenedChange.fire();
|
||||
this._onDidChangeRecentlyOpened.fire();
|
||||
|
||||
// Schedule update to recent documents on macOS dock
|
||||
if (isMacintosh) {
|
||||
@@ -165,7 +165,7 @@ export class WorkspacesHistoryMainService extends Disposable implements IWorkspa
|
||||
|
||||
if (workspaces.length !== mru.workspaces.length || files.length !== mru.files.length) {
|
||||
this.saveRecentlyOpened({ files, workspaces });
|
||||
this._onRecentlyOpenedChange.fire();
|
||||
this._onDidChangeRecentlyOpened.fire();
|
||||
|
||||
// Schedule update to recent documents on macOS dock
|
||||
if (isMacintosh) {
|
||||
@@ -238,7 +238,7 @@ export class WorkspacesHistoryMainService extends Disposable implements IWorkspa
|
||||
app.clearRecentDocuments();
|
||||
|
||||
// Event
|
||||
this._onRecentlyOpenedChange.fire();
|
||||
this._onDidChangeRecentlyOpened.fire();
|
||||
}
|
||||
|
||||
getRecentlyOpened(include?: ICodeWindow): IRecentlyOpened {
|
||||
@@ -350,16 +350,13 @@ export class WorkspacesHistoryMainService extends Disposable implements IWorkspa
|
||||
let hasWorkspaces = false;
|
||||
const items: JumpListItem[] = coalesce(this.getRecentlyOpened().workspaces.slice(0, 7 /* limit number of entries here */).map(recent => {
|
||||
const workspace = isRecentWorkspace(recent) ? recent.workspace : recent.folderUri;
|
||||
const title = recent.label ? splitName(recent.label).name : this.getSimpleWorkspaceLabel(workspace, this.environmentService.untitledWorkspacesHome);
|
||||
|
||||
let description;
|
||||
const { title, description } = this.getWindowsJumpListLabel(workspace, recent.label);
|
||||
let args;
|
||||
if (URI.isUri(workspace)) {
|
||||
description = localize('folderDesc', "{0} {1}", getBaseLabel(workspace), getPathLabel(dirname(workspace), this.environmentService));
|
||||
args = `--folder-uri "${workspace.toString()}"`;
|
||||
} else {
|
||||
hasWorkspaces = true;
|
||||
description = localize('workspaceDesc', "{0} {1}", getBaseLabel(workspace.configPath), getPathLabel(dirname(workspace.configPath), this.environmentService));
|
||||
args = `--file-uri "${workspace.configPath.toString()}"`;
|
||||
}
|
||||
|
||||
@@ -395,16 +392,18 @@ export class WorkspacesHistoryMainService extends Disposable implements IWorkspa
|
||||
}
|
||||
}
|
||||
|
||||
private getSimpleWorkspaceLabel(workspace: IWorkspaceIdentifier | URI, workspaceHome: URI): string {
|
||||
|
||||
private getWindowsJumpListLabel(workspace: IWorkspaceIdentifier | URI, recentLabel: string | undefined): { title: string; description: string } {
|
||||
if (recentLabel) {
|
||||
return { title: splitName(recentLabel).name, description: recentLabel };
|
||||
}
|
||||
// Single Folder
|
||||
if (URI.isUri(workspace)) {
|
||||
return basename(workspace);
|
||||
return { title: basename(workspace), description: renderJumpListPathDescription(workspace) };
|
||||
}
|
||||
|
||||
// Workspace: Untitled
|
||||
if (extUriBiasedIgnorePathCase.isEqualOrParent(workspace.configPath, workspaceHome)) {
|
||||
return localize('untitledWorkspace', "Untitled (Workspace)");
|
||||
if (extUriBiasedIgnorePathCase.isEqualOrParent(workspace.configPath, this.environmentMainService.userHome)) {
|
||||
return { title: localize('untitledWorkspace', "Untitled (Workspace)"), description: '' };
|
||||
}
|
||||
|
||||
// Workspace: normal
|
||||
@@ -413,10 +412,14 @@ export class WorkspacesHistoryMainService extends Disposable implements IWorkspa
|
||||
filename = filename.substr(0, filename.length - WORKSPACE_EXTENSION.length - 1);
|
||||
}
|
||||
|
||||
return localize('workspaceName', "{0} (Workspace)", filename);
|
||||
return { title: localize('workspaceName', "{0} (Workspace)", filename), description: renderJumpListPathDescription(workspace.configPath) };
|
||||
}
|
||||
}
|
||||
|
||||
function renderJumpListPathDescription(uri: URI) {
|
||||
return uri.scheme === 'file' ? normalizeDriveLetter(uri.fsPath) : uri.toString();
|
||||
}
|
||||
|
||||
function location(recent: IRecent): URI {
|
||||
if (isRecentFolder(recent)) {
|
||||
return recent.folderUri;
|
||||
|
||||
@@ -50,7 +50,7 @@ export class WorkspacesMainService implements AddFirstParameterToFunctions<IWork
|
||||
|
||||
//#region Workspaces History
|
||||
|
||||
readonly onRecentlyOpenedChange = this.workspacesHistoryMainService.onRecentlyOpenedChange;
|
||||
readonly onDidChangeRecentlyOpened = this.workspacesHistoryMainService.onDidChangeRecentlyOpened;
|
||||
|
||||
async getRecentlyOpened(windowId: number): Promise<IRecentlyOpened> {
|
||||
return this.workspacesHistoryMainService.getRecentlyOpened(this.windowsMainService.getWindowById(windowId));
|
||||
|
||||
@@ -6,8 +6,8 @@
|
||||
import { toWorkspaceFolders, IWorkspaceIdentifier, hasWorkspaceFileExtension, UNTITLED_WORKSPACE_NAME, IResolvedWorkspace, IStoredWorkspaceFolder, isStoredWorkspaceFolder, IWorkspaceFolderCreationData, IUntitledWorkspaceInfo, getStoredWorkspaceFolder, IEnterWorkspaceResult, isUntitledWorkspace, isWorkspaceIdentifier, ISingleFolderWorkspaceIdentifier } from 'vs/platform/workspaces/common/workspaces';
|
||||
import { IEnvironmentMainService } from 'vs/platform/environment/electron-main/environmentMainService';
|
||||
import { join, dirname } from 'vs/base/common/path';
|
||||
import { mkdirp, writeFile, rimrafSync, readdirSync, writeFileSync } from 'vs/base/node/pfs';
|
||||
import { readFileSync, existsSync, mkdirSync, statSync, Stats } from 'fs';
|
||||
import { writeFile, rimrafSync, readdirSync, writeFileSync } from 'vs/base/node/pfs';
|
||||
import { promises, readFileSync, existsSync, mkdirSync, statSync, Stats } from 'fs';
|
||||
import { isLinux, isMacintosh, isWindows } from 'vs/base/common/platform';
|
||||
import { Event, Emitter } from 'vs/base/common/event';
|
||||
import { ILogService } from 'vs/platform/log/common/log';
|
||||
@@ -38,8 +38,8 @@ export interface IWorkspacesManagementMainService {
|
||||
|
||||
readonly _serviceBrand: undefined;
|
||||
|
||||
readonly onUntitledWorkspaceDeleted: Event<IWorkspaceIdentifier>;
|
||||
readonly onWorkspaceEntered: Event<IWorkspaceEnteredEvent>;
|
||||
readonly onDidDeleteUntitledWorkspace: Event<IWorkspaceIdentifier>;
|
||||
readonly onDidEnterWorkspace: Event<IWorkspaceEnteredEvent>;
|
||||
|
||||
enterWorkspace(intoWindow: ICodeWindow, openedWindows: ICodeWindow[], path: URI): Promise<IEnterWorkspaceResult | null>;
|
||||
|
||||
@@ -65,16 +65,16 @@ export class WorkspacesManagementMainService extends Disposable implements IWork
|
||||
|
||||
declare readonly _serviceBrand: undefined;
|
||||
|
||||
private readonly untitledWorkspacesHome = this.environmentService.untitledWorkspacesHome; // local URI that contains all untitled workspaces
|
||||
private readonly untitledWorkspacesHome = this.environmentMainService.untitledWorkspacesHome; // local URI that contains all untitled workspaces
|
||||
|
||||
private readonly _onUntitledWorkspaceDeleted = this._register(new Emitter<IWorkspaceIdentifier>());
|
||||
readonly onUntitledWorkspaceDeleted: Event<IWorkspaceIdentifier> = this._onUntitledWorkspaceDeleted.event;
|
||||
private readonly _onDidDeleteUntitledWorkspace = this._register(new Emitter<IWorkspaceIdentifier>());
|
||||
readonly onDidDeleteUntitledWorkspace: Event<IWorkspaceIdentifier> = this._onDidDeleteUntitledWorkspace.event;
|
||||
|
||||
private readonly _onWorkspaceEntered = this._register(new Emitter<IWorkspaceEnteredEvent>());
|
||||
readonly onWorkspaceEntered: Event<IWorkspaceEnteredEvent> = this._onWorkspaceEntered.event;
|
||||
private readonly _onDidEnterWorkspace = this._register(new Emitter<IWorkspaceEnteredEvent>());
|
||||
readonly onDidEnterWorkspace: Event<IWorkspaceEnteredEvent> = this._onDidEnterWorkspace.event;
|
||||
|
||||
constructor(
|
||||
@IEnvironmentMainService private readonly environmentService: IEnvironmentMainService,
|
||||
@IEnvironmentMainService private readonly environmentMainService: IEnvironmentMainService,
|
||||
@ILogService private readonly logService: ILogService,
|
||||
@IBackupMainService private readonly backupMainService: IBackupMainService,
|
||||
@IDialogMainService private readonly dialogMainService: IDialogMainService
|
||||
@@ -86,6 +86,7 @@ export class WorkspacesManagementMainService extends Disposable implements IWork
|
||||
if (!this.isWorkspacePath(uri)) {
|
||||
return null; // does not look like a valid workspace config file
|
||||
}
|
||||
|
||||
if (uri.scheme !== Schemas.file) {
|
||||
return null;
|
||||
}
|
||||
@@ -101,7 +102,7 @@ export class WorkspacesManagementMainService extends Disposable implements IWork
|
||||
}
|
||||
|
||||
private isWorkspacePath(uri: URI): boolean {
|
||||
return isUntitledWorkspace(uri, this.environmentService) || hasWorkspaceFileExtension(uri);
|
||||
return isUntitledWorkspace(uri, this.environmentMainService) || hasWorkspaceFileExtension(uri);
|
||||
}
|
||||
|
||||
private doResolveWorkspace(path: URI, contents: string): IResolvedWorkspace | null {
|
||||
@@ -140,7 +141,7 @@ export class WorkspacesManagementMainService extends Disposable implements IWork
|
||||
const { workspace, storedWorkspace } = this.newUntitledWorkspace(folders, remoteAuthority);
|
||||
const configPath = workspace.configPath.fsPath;
|
||||
|
||||
await mkdirp(dirname(configPath));
|
||||
await promises.mkdir(dirname(configPath), { recursive: true });
|
||||
await writeFile(configPath, JSON.stringify(storedWorkspace, null, '\t'));
|
||||
|
||||
return workspace;
|
||||
@@ -186,7 +187,7 @@ export class WorkspacesManagementMainService extends Disposable implements IWork
|
||||
}
|
||||
|
||||
isUntitledWorkspace(workspace: IWorkspaceIdentifier): boolean {
|
||||
return isUntitledWorkspace(workspace.configPath, this.environmentService);
|
||||
return isUntitledWorkspace(workspace.configPath, this.environmentMainService);
|
||||
}
|
||||
|
||||
deleteUntitledWorkspaceSync(workspace: IWorkspaceIdentifier): void {
|
||||
@@ -198,7 +199,7 @@ export class WorkspacesManagementMainService extends Disposable implements IWork
|
||||
this.doDeleteUntitledWorkspaceSync(workspace);
|
||||
|
||||
// Event
|
||||
this._onUntitledWorkspaceDeleted.fire(workspace);
|
||||
this._onDidDeleteUntitledWorkspace.fire(workspace);
|
||||
}
|
||||
|
||||
async deleteUntitledWorkspace(workspace: IWorkspaceIdentifier): Promise<void> {
|
||||
@@ -213,7 +214,7 @@ export class WorkspacesManagementMainService extends Disposable implements IWork
|
||||
rimrafSync(dirname(configPath));
|
||||
|
||||
// Mark Workspace Storage to be deleted
|
||||
const workspaceStoragePath = join(this.environmentService.workspaceStorageHome.fsPath, workspace.id);
|
||||
const workspaceStoragePath = join(this.environmentMainService.workspaceStorageHome.fsPath, workspace.id);
|
||||
if (existsSync(workspaceStoragePath)) {
|
||||
writeFileSync(join(workspaceStoragePath, 'obsolete'), '');
|
||||
}
|
||||
@@ -260,7 +261,7 @@ export class WorkspacesManagementMainService extends Disposable implements IWork
|
||||
}
|
||||
|
||||
// Emit as event
|
||||
this._onWorkspaceEntered.fire({ window, workspace: result.workspace });
|
||||
this._onDidEnterWorkspace.fire({ window, workspace: result.workspace });
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user