mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 10:58:30 -05:00
VS Code merge to df8fe74bd55313de0dd2303bc47a4aab0ca56b0e (#17979)
* Merge from vscode 504f934659740e9d41501cad9f162b54d7745ad9 * delete unused folders * distro * Bump build node version * update chokidar * FIx hygiene errors * distro * Fix extension lint issues * Remove strict-vscode * Add copyright header exemptions * Bump vscode-extension-telemetry to fix webpacking issue with zone.js * distro * Fix failing tests (revert marked.js back to current one until we decide to update) * Skip searchmodel test * Fix mac build * temp debug script loading * Try disabling coverage * log error too * Revert "log error too" This reverts commit af0183e5d4ab458fdf44b88fbfab9908d090526f. * Revert "temp debug script loading" This reverts commit 3d687d541c76db2c5b55626c78ae448d3c25089c. * Add comments explaining coverage disabling * Fix ansi_up loading issue * Merge latest from ads * Use newer option * Fix compile * add debug logging warn * Always log stack * log more * undo debug * Update to use correct base path (+cleanup) * distro * fix compile errors * Remove strict-vscode * Fix sql editors not showing * Show db dropdown input & fix styling * Fix more info in gallery * Fix gallery asset requests * Delete unused workflow * Fix tapable resolutions for smoke test compile error * Fix smoke compile * Disable crash reporting * Disable interactive Co-authored-by: ADS Merger <karlb@microsoft.com>
This commit is contained in:
@@ -3,49 +3,50 @@
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { app, BrowserWindow, MessageBoxOptions, nativeTheme, WebContents } from 'electron';
|
||||
import { statSync } from 'fs';
|
||||
import { release, hostname } from 'os';
|
||||
import product from 'vs/platform/product/common/product';
|
||||
import { mark, getMarks } from 'vs/base/common/performance';
|
||||
import { basename, normalize, join, posix } from 'vs/base/common/path';
|
||||
import { localize } from 'vs/nls';
|
||||
import { hostname, release } from 'os';
|
||||
import { coalesce, distinct, firstOrDefault } from 'vs/base/common/arrays';
|
||||
import { CancellationToken } from 'vs/base/common/cancellation';
|
||||
import { CharCode } from 'vs/base/common/charCode';
|
||||
import { Emitter, Event } from 'vs/base/common/event';
|
||||
import { isWindowsDriveLetter, parseLineAndColumnAware, sanitizeFilePath, toSlashes } from 'vs/base/common/extpath';
|
||||
import { once } from 'vs/base/common/functional';
|
||||
import { getPathLabel, mnemonicButtonLabel } from 'vs/base/common/labels';
|
||||
import { Disposable, DisposableStore } from 'vs/base/common/lifecycle';
|
||||
import { Schemas } from 'vs/base/common/network';
|
||||
import { basename, join, normalize, posix } from 'vs/base/common/path';
|
||||
import { getMarks, mark } from 'vs/base/common/performance';
|
||||
import { IProcessEnvironment, isMacintosh } from 'vs/base/common/platform';
|
||||
import { cwd } from 'vs/base/common/process';
|
||||
import { extUriBiasedIgnorePathCase, normalizePath, originalFSPath, removeTrailingPathSeparator } from 'vs/base/common/resources';
|
||||
import { assertIsDefined, withNullAsUndefined } from 'vs/base/common/types';
|
||||
import { URI } from 'vs/base/common/uri';
|
||||
import { localize } from 'vs/nls';
|
||||
import { IBackupMainService } from 'vs/platform/backup/electron-main/backup';
|
||||
import { IEmptyWindowBackupInfo } from 'vs/platform/backup/node/backup';
|
||||
import { IEnvironmentMainService } from 'vs/platform/environment/electron-main/environmentMainService';
|
||||
import { NativeParsedArgs } from 'vs/platform/environment/common/argv';
|
||||
import { IStateMainService } from 'vs/platform/state/electron-main/state';
|
||||
import { CodeWindow } from 'vs/platform/windows/electron-main/window';
|
||||
import { app, BrowserWindow, MessageBoxOptions, nativeTheme, WebContents } from 'electron';
|
||||
import { ILifecycleMainService, UnloadReason } from 'vs/platform/lifecycle/electron-main/lifecycleMainService';
|
||||
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
|
||||
import { ILogService } from 'vs/platform/log/common/log';
|
||||
import { IWindowSettings, IPath, isFileToOpen, isWorkspaceToOpen, isFolderToOpen, IWindowOpenable, IOpenEmptyWindowOptions, IAddFoldersRequest, IPathsToWaitFor, INativeWindowConfiguration, INativeOpenFileRequest } from 'vs/platform/windows/common/windows';
|
||||
import { findWindowOnFile, findWindowOnWorkspaceOrFolder, findWindowOnExtensionDevelopmentPath } from 'vs/platform/windows/electron-main/windowsFinder';
|
||||
import { Event, Emitter } from 'vs/base/common/event';
|
||||
import { IProductService } from 'vs/platform/product/common/productService';
|
||||
import { IWindowsMainService, IOpenConfiguration, IWindowsCountChangedEvent, ICodeWindow, IOpenEmptyConfiguration, OpenContext } from 'vs/platform/windows/electron-main/windows';
|
||||
import { IWorkspacesHistoryMainService } from 'vs/platform/workspaces/electron-main/workspacesHistoryMainService';
|
||||
import { IProcessEnvironment, isMacintosh } from 'vs/base/common/platform';
|
||||
import { IWorkspaceIdentifier, hasWorkspaceFileExtension, IRecent, isWorkspaceIdentifier, isSingleFolderWorkspaceIdentifier, ISingleFolderWorkspaceIdentifier } from 'vs/platform/workspaces/common/workspaces';
|
||||
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
|
||||
import { Schemas } from 'vs/base/common/network';
|
||||
import { URI } from 'vs/base/common/uri';
|
||||
import { normalizePath, originalFSPath, removeTrailingPathSeparator, extUriBiasedIgnorePathCase } from 'vs/base/common/resources';
|
||||
import { getRemoteAuthority } from 'vs/platform/remote/common/remoteHosts';
|
||||
import { IWindowState, WindowsStateHandler } from 'vs/platform/windows/electron-main/windowsStateHandler';
|
||||
import { getSingleFolderWorkspaceIdentifier, getWorkspaceIdentifier, IWorkspacesManagementMainService } from 'vs/platform/workspaces/electron-main/workspacesManagementMainService';
|
||||
import { once } from 'vs/base/common/functional';
|
||||
import { Disposable, DisposableStore } from 'vs/base/common/lifecycle';
|
||||
import { IDialogMainService } from 'vs/platform/dialogs/electron-main/dialogMainService';
|
||||
import { assertIsDefined, withNullAsUndefined } from 'vs/base/common/types';
|
||||
import { isWindowsDriveLetter, toSlashes, parseLineAndColumnAware, sanitizeFilePath } from 'vs/base/common/extpath';
|
||||
import { CharCode } from 'vs/base/common/charCode';
|
||||
import { getPathLabel } from 'vs/base/common/labels';
|
||||
import { CancellationToken } from 'vs/base/common/cancellation';
|
||||
import { NativeParsedArgs } from 'vs/platform/environment/common/argv';
|
||||
import { IEnvironmentMainService } from 'vs/platform/environment/electron-main/environmentMainService';
|
||||
import { IFileService } from 'vs/platform/files/common/files';
|
||||
import { cwd } from 'vs/base/common/process';
|
||||
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
|
||||
import { ILifecycleMainService } from 'vs/platform/lifecycle/electron-main/lifecycleMainService';
|
||||
import { ILogService } from 'vs/platform/log/common/log';
|
||||
import product from 'vs/platform/product/common/product';
|
||||
import { IProductService } from 'vs/platform/product/common/productService';
|
||||
import { IProtocolMainService } from 'vs/platform/protocol/electron-main/protocol';
|
||||
import { getRemoteAuthority } from 'vs/platform/remote/common/remoteHosts';
|
||||
import { IStateMainService } from 'vs/platform/state/electron-main/state';
|
||||
import { IAddFoldersRequest, INativeOpenFileRequest, INativeWindowConfiguration, IOpenEmptyWindowOptions, IPath, IPathsToWaitFor, isFileToOpen, isFolderToOpen, isWorkspaceToOpen, IWindowOpenable, IWindowSettings } from 'vs/platform/windows/common/windows';
|
||||
import { CodeWindow } from 'vs/platform/windows/electron-main/window';
|
||||
import { ICodeWindow, IOpenConfiguration, IOpenEmptyConfiguration, IWindowsCountChangedEvent, IWindowsMainService, OpenContext, UnloadReason } from 'vs/platform/windows/electron-main/windows';
|
||||
import { findWindowOnExtensionDevelopmentPath, findWindowOnFile, findWindowOnWorkspaceOrFolder } from 'vs/platform/windows/electron-main/windowsFinder';
|
||||
import { IWindowState, WindowsStateHandler } from 'vs/platform/windows/electron-main/windowsStateHandler';
|
||||
import { hasWorkspaceFileExtension, IRecent, ISingleFolderWorkspaceIdentifier, isSingleFolderWorkspaceIdentifier, isWorkspaceIdentifier, IWorkspaceIdentifier } from 'vs/platform/workspaces/common/workspaces';
|
||||
import { getSingleFolderWorkspaceIdentifier, getWorkspaceIdentifier } from 'vs/platform/workspaces/electron-main/workspaces';
|
||||
import { IWorkspacesHistoryMainService } from 'vs/platform/workspaces/electron-main/workspacesHistoryMainService';
|
||||
import { IWorkspacesManagementMainService } from 'vs/platform/workspaces/electron-main/workspacesManagementMainService';
|
||||
|
||||
//#region Helper Interfaces
|
||||
|
||||
@@ -71,11 +72,37 @@ interface IOpenBrowserWindowOptions {
|
||||
}
|
||||
|
||||
interface IPathResolveOptions {
|
||||
readonly ignoreFileNotFound?: boolean;
|
||||
readonly gotoLineMode?: boolean;
|
||||
readonly forceOpenWorkspaceAsFile?: boolean;
|
||||
|
||||
/**
|
||||
* The remoteAuthority to use if the URL to open is neither file nor vscode-remote
|
||||
* By default, resolving a path will check
|
||||
* if the path exists. This can be disabled
|
||||
* with this flag.
|
||||
*/
|
||||
readonly ignoreFileNotFound?: boolean;
|
||||
|
||||
/**
|
||||
* Will reject a path if it points to a transient
|
||||
* workspace as indicated by a `transient: true`
|
||||
* property in the workspace file.
|
||||
*/
|
||||
readonly rejectTransientWorkspaces?: boolean;
|
||||
|
||||
/**
|
||||
* If enabled, will resolve the path line/column
|
||||
* aware and properly remove this information
|
||||
* from the resulting file path.
|
||||
*/
|
||||
readonly gotoLineMode?: boolean;
|
||||
|
||||
/**
|
||||
* Forces to resolve the provided path as workspace
|
||||
* file instead of opening it as a file.
|
||||
*/
|
||||
readonly forceOpenWorkspaceAsFile?: boolean;
|
||||
|
||||
/**
|
||||
* The remoteAuthority to use if the URL to open is
|
||||
* neither `file` nor `vscode-remote`.
|
||||
*/
|
||||
readonly remoteAuthority?: string;
|
||||
}
|
||||
@@ -93,6 +120,11 @@ interface IPathToOpen extends IPath {
|
||||
// the workspace to open
|
||||
readonly workspace?: IWorkspaceIdentifier | ISingleFolderWorkspaceIdentifier;
|
||||
|
||||
// whether the path is considered to be transient or not
|
||||
// for example, a transient workspace should not add to
|
||||
// the workspaces history and should never restore
|
||||
readonly transient?: boolean;
|
||||
|
||||
// the backup path to use
|
||||
readonly backupPath?: string;
|
||||
|
||||
@@ -208,9 +240,12 @@ export class WindowsMainService extends Disposable implements IWindowsMainServic
|
||||
|
||||
const foldersToAdd: ISingleFolderWorkspacePathToOpen[] = [];
|
||||
const foldersToOpen: ISingleFolderWorkspacePathToOpen[] = [];
|
||||
|
||||
const workspacesToOpen: IWorkspacePathToOpen[] = [];
|
||||
const workspacesToRestore: IWorkspacePathToOpen[] = [];
|
||||
const emptyToRestore: IEmptyWindowBackupInfo[] = [];
|
||||
const untitledWorkspacesToRestore: IWorkspacePathToOpen[] = [];
|
||||
|
||||
const emptyWindowsWithBackupsToRestore: IEmptyWindowBackupInfo[] = [];
|
||||
|
||||
let filesToOpen: IFilesToOpen | undefined;
|
||||
let emptyToOpen = 0;
|
||||
|
||||
@@ -234,7 +269,7 @@ export class WindowsMainService extends Disposable implements IWindowsMainServic
|
||||
}
|
||||
filesToOpen.filesToOpenOrCreate.push(path);
|
||||
} else if (path.backupPath) {
|
||||
emptyToRestore.push({ backupFolder: basename(path.backupPath), remoteAuthority: path.remoteAuthority });
|
||||
emptyWindowsWithBackupsToRestore.push({ backupFolder: basename(path.backupPath), remoteAuthority: path.remoteAuthority });
|
||||
} else {
|
||||
emptyToOpen++;
|
||||
}
|
||||
@@ -256,19 +291,19 @@ export class WindowsMainService extends Disposable implements IWindowsMainServic
|
||||
if (openConfig.initialStartup) {
|
||||
|
||||
// Untitled workspaces are always restored
|
||||
workspacesToRestore.push(...this.workspacesManagementMainService.getUntitledWorkspacesSync());
|
||||
workspacesToOpen.push(...workspacesToRestore);
|
||||
untitledWorkspacesToRestore.push(...this.workspacesManagementMainService.getUntitledWorkspacesSync());
|
||||
workspacesToOpen.push(...untitledWorkspacesToRestore);
|
||||
|
||||
// Empty windows with backups are always restored
|
||||
emptyToRestore.push(...this.backupMainService.getEmptyWindowBackupPaths());
|
||||
emptyWindowsWithBackupsToRestore.push(...this.backupMainService.getEmptyWindowBackupPaths());
|
||||
} else {
|
||||
emptyToRestore.length = 0;
|
||||
emptyWindowsWithBackupsToRestore.length = 0;
|
||||
}
|
||||
|
||||
// Open based on config
|
||||
const { windows: usedWindows, filesOpenedInWindow } = this.doOpen(openConfig, workspacesToOpen, foldersToOpen, emptyToRestore, emptyToOpen, filesToOpen, foldersToAdd);
|
||||
const { windows: usedWindows, filesOpenedInWindow } = this.doOpen(openConfig, workspacesToOpen, foldersToOpen, emptyWindowsWithBackupsToRestore, emptyToOpen, filesToOpen, foldersToAdd);
|
||||
|
||||
this.logService.trace(`windowsManager#open used window count ${usedWindows.length} (workspacesToOpen: ${workspacesToOpen.length}, foldersToOpen: ${foldersToOpen.length}, emptyToRestore: ${emptyToRestore.length}, emptyToOpen: ${emptyToOpen})`);
|
||||
this.logService.trace(`windowsManager#open used window count ${usedWindows.length} (workspacesToOpen: ${workspacesToOpen.length}, foldersToOpen: ${foldersToOpen.length}, emptyToRestore: ${emptyWindowsWithBackupsToRestore.length}, emptyToOpen: ${emptyToOpen})`);
|
||||
|
||||
// Make sure to pass focus to the most relevant of the windows if we open multiple
|
||||
if (usedWindows.length > 1) {
|
||||
@@ -299,8 +334,8 @@ export class WindowsMainService extends Disposable implements IWindowsMainServic
|
||||
for (let i = usedWindows.length - 1; i >= 0; i--) {
|
||||
const usedWindow = usedWindows[i];
|
||||
if (
|
||||
(usedWindow.openedWorkspace && workspacesToRestore.some(workspace => usedWindow.openedWorkspace && workspace.workspace.id === usedWindow.openedWorkspace.id)) || // skip over restored workspace
|
||||
(usedWindow.backupPath && emptyToRestore.some(empty => usedWindow.backupPath && empty.backupFolder === basename(usedWindow.backupPath))) // skip over restored empty window
|
||||
(usedWindow.openedWorkspace && untitledWorkspacesToRestore.some(workspace => usedWindow.openedWorkspace && workspace.workspace.id === usedWindow.openedWorkspace.id)) || // skip over restored workspace
|
||||
(usedWindow.backupPath && emptyWindowsWithBackupsToRestore.some(empty => usedWindow.backupPath && empty.backupFolder === basename(usedWindow.backupPath))) // skip over restored empty window
|
||||
) {
|
||||
continue;
|
||||
}
|
||||
@@ -324,7 +359,7 @@ export class WindowsMainService extends Disposable implements IWindowsMainServic
|
||||
if (!usedWindows.some(window => window.isExtensionDevelopmentHost) && !isDiff && !openConfig.noRecentEntry) {
|
||||
const recents: IRecent[] = [];
|
||||
for (const pathToOpen of pathsToOpen) {
|
||||
if (isWorkspacePathToOpen(pathToOpen)) {
|
||||
if (isWorkspacePathToOpen(pathToOpen) && !pathToOpen.transient /* never add transient workspaces to history */) {
|
||||
recents.push({ label: pathToOpen.label, workspace: pathToOpen.workspace, remoteAuthority: pathToOpen.remoteAuthority });
|
||||
} else if (isSingleFolderWorkspacePathToOpen(pathToOpen)) {
|
||||
recents.push({ label: pathToOpen.label, folderUri: pathToOpen.workspace.uri, remoteAuthority: pathToOpen.remoteAuthority });
|
||||
@@ -702,10 +737,11 @@ export class WindowsMainService extends Disposable implements IWindowsMainServic
|
||||
const options: MessageBoxOptions = {
|
||||
title: this.productService.nameLong,
|
||||
type: 'info',
|
||||
buttons: [localize('ok', "OK")],
|
||||
buttons: [mnemonicButtonLabel(localize({ key: 'ok', comment: ['&& denotes a mnemonic'] }, "&&OK"))],
|
||||
defaultId: 0,
|
||||
message: uri.scheme === Schemas.file ? localize('pathNotExistTitle', "Path does not exist") : localize('uriInvalidTitle', "URI can not be opened"),
|
||||
detail: uri.scheme === Schemas.file ?
|
||||
localize('pathNotExistDetail', "The path '{0}' does not seem to exist anymore on disk.", getPathLabel(uri.fsPath, this.environmentMainService)) :
|
||||
localize('pathNotExistDetail', "The path '{0}' does not exist on this computer.", getPathLabel(uri.fsPath, this.environmentMainService)) :
|
||||
localize('uriInvalidDetail', "The URI '{0}' is not valid and can not be opened.", uri.toString()),
|
||||
noLink: true
|
||||
};
|
||||
@@ -808,7 +844,7 @@ export class WindowsMainService extends Disposable implements IWindowsMainServic
|
||||
|
||||
// Workspaces
|
||||
if (lastSessionWindow.workspace) {
|
||||
const pathToOpen = this.resolveOpenable({ workspaceUri: lastSessionWindow.workspace.configPath }, { remoteAuthority: lastSessionWindow.remoteAuthority });
|
||||
const pathToOpen = this.resolveOpenable({ workspaceUri: lastSessionWindow.workspace.configPath }, { remoteAuthority: lastSessionWindow.remoteAuthority, rejectTransientWorkspaces: true /* https://github.com/microsoft/vscode/issues/119695 */ });
|
||||
if (isWorkspacePathToOpen(pathToOpen)) {
|
||||
pathsToOpen.push(pathToOpen);
|
||||
}
|
||||
@@ -848,7 +884,7 @@ export class WindowsMainService extends Disposable implements IWindowsMainServic
|
||||
return restoreWindows;
|
||||
}
|
||||
|
||||
private resolveOpenable(openable: IWindowOpenable, options: IPathResolveOptions = {}): IPathToOpen | undefined {
|
||||
private resolveOpenable(openable: IWindowOpenable, options: IPathResolveOptions = Object.create(null)): IPathToOpen | undefined {
|
||||
|
||||
// handle file:// openables with some extra validation
|
||||
let uri = this.resourceFromOpenable(openable);
|
||||
@@ -878,7 +914,11 @@ export class WindowsMainService extends Disposable implements IWindowsMainServic
|
||||
if (options.gotoLineMode) {
|
||||
const { path, line, column } = parseLineAndColumnAware(uri.path);
|
||||
|
||||
return { fileUri: uri.with({ path }), lineNumber: line, columnNumber: column, remoteAuthority };
|
||||
return {
|
||||
fileUri: uri.with({ path }),
|
||||
selection: line ? { startLineNumber: line, startColumn: column || 1 } : undefined,
|
||||
remoteAuthority
|
||||
};
|
||||
}
|
||||
|
||||
return { fileUri: uri, remoteAuthority };
|
||||
@@ -910,7 +950,6 @@ export class WindowsMainService extends Disposable implements IWindowsMainServic
|
||||
// Extract line/col information from path
|
||||
let lineNumber: number | undefined;
|
||||
let columnNumber: number | undefined;
|
||||
|
||||
if (options.gotoLineMode) {
|
||||
({ path, line: lineNumber, column: columnNumber } = parseLineAndColumnAware(path));
|
||||
}
|
||||
@@ -926,12 +965,23 @@ export class WindowsMainService extends Disposable implements IWindowsMainServic
|
||||
if (!options.forceOpenWorkspaceAsFile) {
|
||||
const workspace = this.workspacesManagementMainService.resolveLocalWorkspaceSync(URI.file(path));
|
||||
if (workspace) {
|
||||
return { workspace: { id: workspace.id, configPath: workspace.configPath }, remoteAuthority: workspace.remoteAuthority, exists: true };
|
||||
|
||||
// If the workspace is transient and we are to ignore
|
||||
// transient workspaces, reject it.
|
||||
if (workspace.transient && options.rejectTransientWorkspaces) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
return { workspace: { id: workspace.id, configPath: workspace.configPath }, remoteAuthority: workspace.remoteAuthority, exists: true, transient: workspace.transient };
|
||||
}
|
||||
}
|
||||
|
||||
// File
|
||||
return { fileUri: URI.file(path), lineNumber, columnNumber, exists: true };
|
||||
return {
|
||||
fileUri: URI.file(path),
|
||||
selection: lineNumber ? { startLineNumber: lineNumber, startColumn: columnNumber || 1 } : undefined,
|
||||
exists: true
|
||||
};
|
||||
}
|
||||
|
||||
// Folder (we check for isDirectory() because e.g. paths like /dev/null
|
||||
@@ -987,14 +1037,23 @@ export class WindowsMainService extends Disposable implements IWindowsMainServic
|
||||
// file name ends with .code-workspace
|
||||
if (hasWorkspaceFileExtension(path)) {
|
||||
if (options.forceOpenWorkspaceAsFile) {
|
||||
return { fileUri: uri, lineNumber, columnNumber, remoteAuthority: options.remoteAuthority };
|
||||
return {
|
||||
fileUri: uri,
|
||||
selection: lineNumber ? { startLineNumber: lineNumber, startColumn: columnNumber || 1 } : undefined,
|
||||
remoteAuthority: options.remoteAuthority
|
||||
};
|
||||
}
|
||||
|
||||
return { workspace: getWorkspaceIdentifier(uri), remoteAuthority };
|
||||
}
|
||||
|
||||
// file name starts with a dot or has an file extension
|
||||
else if (options.gotoLineMode || posix.basename(path).indexOf('.') !== -1) {
|
||||
return { fileUri: uri, lineNumber, columnNumber, remoteAuthority };
|
||||
return {
|
||||
fileUri: uri,
|
||||
selection: lineNumber ? { startLineNumber: lineNumber, startColumn: columnNumber || 1 } : undefined,
|
||||
remoteAuthority
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user