mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 10:58:30 -05:00
Merge from vscode 4d91d96e5e121b38d33508cdef17868bab255eae
This commit is contained in:
committed by
AzureDataStudio
parent
a971aee5bd
commit
5e7071e466
@@ -166,6 +166,9 @@ export interface IPathData {
|
||||
|
||||
// Specifies if the file should be only be opened if it exists
|
||||
openOnlyIfExists?: boolean;
|
||||
|
||||
// Specifies an optional id to override the editor used to edit the resource, e.g. custom editor.
|
||||
overrideId?: string;
|
||||
}
|
||||
|
||||
export interface IOpenFileRequest {
|
||||
|
||||
@@ -33,9 +33,6 @@ export const enum WindowMode {
|
||||
|
||||
export interface ICodeWindow extends IDisposable {
|
||||
|
||||
readonly onClose: Event<void>;
|
||||
readonly onDestroy: Event<void>;
|
||||
|
||||
readonly whenClosedOrLoaded: Promise<void>;
|
||||
|
||||
readonly id: number;
|
||||
@@ -99,7 +96,7 @@ export interface IWindowsCountChangedEvent {
|
||||
|
||||
export interface IWindowsMainService {
|
||||
|
||||
_serviceBrand: undefined;
|
||||
readonly _serviceBrand: undefined;
|
||||
|
||||
readonly onWindowReady: Event<ICodeWindow>;
|
||||
readonly onWindowsCountChanged: Event<IWindowsCountChangedEvent>;
|
||||
|
||||
@@ -15,7 +15,7 @@ import { ParsedArgs } from 'vs/platform/environment/node/argv';
|
||||
import { INativeEnvironmentService } from 'vs/platform/environment/node/environmentService';
|
||||
import { IStateService } from 'vs/platform/state/node/state';
|
||||
import { CodeWindow, defaultWindowState } from 'vs/code/electron-main/window';
|
||||
import { ipcMain as ipc, screen, BrowserWindow, MessageBoxOptions, Display, app, nativeTheme } from 'electron';
|
||||
import { screen, BrowserWindow, MessageBoxOptions, Display, app, nativeTheme } from 'electron';
|
||||
import { ILifecycleMainService, UnloadReason, LifecycleMainService, LifecycleMainPhase } from 'vs/platform/lifecycle/electron-main/lifecycleMainService';
|
||||
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
|
||||
import { ILogService } from 'vs/platform/log/common/log';
|
||||
@@ -30,7 +30,7 @@ import { IWorkspaceIdentifier, isSingleFolderWorkspaceIdentifier, hasWorkspaceFi
|
||||
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
|
||||
import { Schemas } from 'vs/base/common/network';
|
||||
import { URI } from 'vs/base/common/uri';
|
||||
import { getComparisonKey, isEqual, normalizePath, originalFSPath, removeTrailingPathSeparator } from 'vs/base/common/resources';
|
||||
import { normalizePath, originalFSPath, removeTrailingPathSeparator, extUriBiasedIgnorePathCase } from 'vs/base/common/resources';
|
||||
import { getRemoteAuthority } from 'vs/platform/remote/common/remoteHosts';
|
||||
import { restoreWindowsState, WindowsStateStorageData, getWindowsStateStoreData } from 'vs/platform/windows/electron-main/windowsStateStorage';
|
||||
import { getWorkspaceIdentifier, IWorkspacesMainService } from 'vs/platform/workspaces/electron-main/workspacesMainService';
|
||||
@@ -152,7 +152,7 @@ interface IWorkspacePathToOpen {
|
||||
|
||||
export class WindowsMainService extends Disposable implements IWindowsMainService {
|
||||
|
||||
_serviceBrand: undefined;
|
||||
declare readonly _serviceBrand: undefined;
|
||||
|
||||
private static readonly windowsStateStorageKey = 'windowsState';
|
||||
|
||||
@@ -212,19 +212,6 @@ export class WindowsMainService extends Disposable implements IWindowsMainServic
|
||||
|
||||
private registerListeners(): void {
|
||||
|
||||
// React to workbench ready events from windows
|
||||
ipc.on('vscode:workbenchReady', (event: Event, windowId: number) => {
|
||||
this.logService.trace('IPC#vscode-workbenchReady');
|
||||
|
||||
const win = this.getWindowById(windowId);
|
||||
if (win) {
|
||||
win.setReady();
|
||||
|
||||
// Event
|
||||
this._onWindowReady.fire(win);
|
||||
}
|
||||
});
|
||||
|
||||
// React to HC color scheme changes (Windows)
|
||||
if (isWindows) {
|
||||
nativeTheme.on('updated', () => {
|
||||
@@ -365,7 +352,7 @@ export class WindowsMainService extends Disposable implements IWindowsMainServic
|
||||
else if (!win.isExtensionDevelopmentHost && (!!win.openedWorkspace || !!win.openedFolderUri)) {
|
||||
this.windowsState.openedWindows.forEach(o => {
|
||||
const sameWorkspace = win.openedWorkspace && o.workspace && o.workspace.id === win.openedWorkspace.id;
|
||||
const sameFolder = win.openedFolderUri && o.folderUri && isEqual(o.folderUri, win.openedFolderUri);
|
||||
const sameFolder = win.openedFolderUri && o.folderUri && extUriBiasedIgnorePathCase.isEqual(o.folderUri, win.openedFolderUri);
|
||||
|
||||
if (sameWorkspace || sameFolder) {
|
||||
o.uiState = state.uiState;
|
||||
@@ -673,7 +660,7 @@ export class WindowsMainService extends Disposable implements IWindowsMainServic
|
||||
}
|
||||
|
||||
// Handle folders to open (instructed and to restore)
|
||||
const allFoldersToOpen = arrays.distinct(foldersToOpen, folder => getComparisonKey(folder.folderUri)); // prevent duplicates
|
||||
const allFoldersToOpen = arrays.distinct(foldersToOpen, folder => extUriBiasedIgnorePathCase.getComparisonKey(folder.folderUri)); // prevent duplicates
|
||||
if (allFoldersToOpen.length > 0) {
|
||||
|
||||
// Check for existing instances
|
||||
@@ -696,7 +683,7 @@ export class WindowsMainService extends Disposable implements IWindowsMainServic
|
||||
// Open remaining ones
|
||||
allFoldersToOpen.forEach(folderToOpen => {
|
||||
|
||||
if (windowsOnFolderPath.some(win => isEqual(win.openedFolderUri, folderToOpen.folderUri))) {
|
||||
if (windowsOnFolderPath.some(win => extUriBiasedIgnorePathCase.isEqual(win.openedFolderUri, folderToOpen.folderUri))) {
|
||||
return; // ignore folders that are already open
|
||||
}
|
||||
|
||||
@@ -1434,24 +1421,25 @@ export class WindowsMainService extends Disposable implements IWindowsMainServic
|
||||
if (options.forceNewTabbedWindow) {
|
||||
const activeWindow = this.getLastActiveWindow();
|
||||
if (activeWindow) {
|
||||
activeWindow.addTabbedWindow(window);
|
||||
activeWindow.addTabbedWindow(createdWindow);
|
||||
}
|
||||
}
|
||||
|
||||
// Add to our list of windows
|
||||
WindowsMainService.WINDOWS.push(window);
|
||||
WindowsMainService.WINDOWS.push(createdWindow);
|
||||
|
||||
// Indicate number change via event
|
||||
this._onWindowsCountChanged.fire({ oldCount: WindowsMainService.WINDOWS.length - 1, newCount: WindowsMainService.WINDOWS.length });
|
||||
|
||||
// Window Events
|
||||
once(window.onClose)(() => this.onWindowClosed(createdWindow));
|
||||
once(window.onDestroy)(() => this.onBeforeWindowClose(createdWindow)); // try to save state before destroy because close will not fire
|
||||
window.win.webContents.removeAllListeners('devtools-reload-page'); // remove built in listener so we can handle this on our own
|
||||
window.win.webContents.on('devtools-reload-page', () => this.lifecycleMainService.reload(createdWindow));
|
||||
once(createdWindow.onReady)(() => this._onWindowReady.fire(createdWindow));
|
||||
once(createdWindow.onClose)(() => this.onWindowClosed(createdWindow));
|
||||
once(createdWindow.onDestroy)(() => this.onBeforeWindowClose(createdWindow)); // try to save state before destroy because close will not fire
|
||||
createdWindow.win.webContents.removeAllListeners('devtools-reload-page'); // remove built in listener so we can handle this on our own
|
||||
createdWindow.win.webContents.on('devtools-reload-page', () => this.lifecycleMainService.reload(createdWindow));
|
||||
|
||||
// Lifecycle
|
||||
(this.lifecycleMainService as LifecycleMainService).registerWindow(window);
|
||||
(this.lifecycleMainService as LifecycleMainService).registerWindow(createdWindow);
|
||||
}
|
||||
|
||||
// Existing window
|
||||
@@ -1526,7 +1514,7 @@ export class WindowsMainService extends Disposable implements IWindowsMainServic
|
||||
|
||||
// Known Folder - load from stored settings
|
||||
if (configuration.folderUri) {
|
||||
const stateForFolder = this.windowsState.openedWindows.filter(o => o.folderUri && isEqual(o.folderUri, configuration.folderUri)).map(o => o.uiState);
|
||||
const stateForFolder = this.windowsState.openedWindows.filter(o => o.folderUri && extUriBiasedIgnorePathCase.isEqual(o.folderUri, configuration.folderUri)).map(o => o.uiState);
|
||||
if (stateForFolder.length) {
|
||||
return stateForFolder[0];
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ import { URI, UriComponents } from 'vs/base/common/uri';
|
||||
import * as platform from 'vs/base/common/platform';
|
||||
import * as extpath from 'vs/base/common/extpath';
|
||||
import { IWorkspaceIdentifier, IResolvedWorkspace, ISingleFolderWorkspaceIdentifier, isSingleFolderWorkspaceIdentifier, isWorkspaceIdentifier } from 'vs/platform/workspaces/common/workspaces';
|
||||
import { isEqual, isEqualOrParent } from 'vs/base/common/resources';
|
||||
import { extUriBiasedIgnorePathCase } from 'vs/base/common/resources';
|
||||
import { LogLevel } from 'vs/platform/log/common/log';
|
||||
import { ExportData } from 'vs/base/common/performance';
|
||||
import { ParsedArgs } from 'vs/platform/environment/node/argv';
|
||||
@@ -124,12 +124,12 @@ function findWindowOnFilePath<W extends IWindowContext>(windows: W[], fileUri: U
|
||||
const resolvedWorkspace = localWorkspaceResolver(workspace);
|
||||
if (resolvedWorkspace) {
|
||||
// workspace could be resolved: It's in the local file system
|
||||
if (resolvedWorkspace.folders.some(folder => isEqualOrParent(fileUri, folder.uri))) {
|
||||
if (resolvedWorkspace.folders.some(folder => extUriBiasedIgnorePathCase.isEqualOrParent(fileUri, folder.uri))) {
|
||||
return window;
|
||||
}
|
||||
} else {
|
||||
// use the config path instead
|
||||
if (isEqualOrParent(fileUri, workspace.configPath)) {
|
||||
if (extUriBiasedIgnorePathCase.isEqualOrParent(fileUri, workspace.configPath)) {
|
||||
return window;
|
||||
}
|
||||
}
|
||||
@@ -137,7 +137,7 @@ function findWindowOnFilePath<W extends IWindowContext>(windows: W[], fileUri: U
|
||||
}
|
||||
|
||||
// Then go with single folder windows that are parent of the provided file path
|
||||
const singleFolderWindowsOnFilePath = windows.filter(window => window.openedFolderUri && isEqualOrParent(fileUri, window.openedFolderUri));
|
||||
const singleFolderWindowsOnFilePath = windows.filter(window => window.openedFolderUri && extUriBiasedIgnorePathCase.isEqualOrParent(fileUri, window.openedFolderUri));
|
||||
if (singleFolderWindowsOnFilePath.length) {
|
||||
return singleFolderWindowsOnFilePath.sort((a, b) => -(a.openedFolderUri!.path.length - b.openedFolderUri!.path.length))[0];
|
||||
}
|
||||
@@ -156,7 +156,7 @@ export function findWindowOnWorkspace<W extends IWindowContext>(windows: W[], wo
|
||||
for (const window of windows) {
|
||||
// match on folder
|
||||
if (isSingleFolderWorkspaceIdentifier(workspace)) {
|
||||
if (window.openedFolderUri && isEqual(window.openedFolderUri, workspace)) {
|
||||
if (window.openedFolderUri && extUriBiasedIgnorePathCase.isEqual(window.openedFolderUri, workspace)) {
|
||||
return window;
|
||||
}
|
||||
}
|
||||
@@ -195,12 +195,12 @@ export function findWindowOnWorkspaceOrFolderUri<W extends IWindowContext>(windo
|
||||
}
|
||||
for (const window of windows) {
|
||||
// check for workspace config path
|
||||
if (window.openedWorkspace && isEqual(window.openedWorkspace.configPath, uri)) {
|
||||
if (window.openedWorkspace && extUriBiasedIgnorePathCase.isEqual(window.openedWorkspace.configPath, uri)) {
|
||||
return window;
|
||||
}
|
||||
|
||||
// check for folder path
|
||||
if (window.openedFolderUri && isEqual(window.openedFolderUri, uri)) {
|
||||
if (window.openedFolderUri && extUriBiasedIgnorePathCase.isEqual(window.openedFolderUri, uri)) {
|
||||
return window;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user