mirror of
https://github.com/Microsoft/vscode
synced 2024-08-27 13:00:58 +00:00
Remote file not opened in existing remote window. Fixes #131731
This commit is contained in:
parent
c38d441d37
commit
3eeb80e04e
|
@ -20,6 +20,7 @@ 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 { equalsIgnoreCase } from 'vs/base/common/strings';
|
||||
import { assertIsDefined, withNullAsUndefined } from 'vs/base/common/types';
|
||||
import { URI } from 'vs/base/common/uri';
|
||||
import { localize } from 'vs/nls';
|
||||
|
@ -448,7 +449,7 @@ export class WindowsMainService extends Disposable implements IWindowsMainServic
|
|||
const fileToCheck = filesToOpen.filesToOpenOrCreate[0] || filesToOpen.filesToDiff[0];
|
||||
|
||||
// only look at the windows with correct authority
|
||||
const windows = this.getWindows().filter(window => filesToOpen && window.remoteAuthority === filesToOpen.remoteAuthority);
|
||||
const windows = this.getWindows().filter(window => filesToOpen && isEqualAuthority(window.remoteAuthority, filesToOpen.remoteAuthority));
|
||||
|
||||
// figure out a good window to open the files in if any
|
||||
// with a fallback to the last active window.
|
||||
|
@ -507,7 +508,7 @@ export class WindowsMainService extends Disposable implements IWindowsMainServic
|
|||
const windowsOnWorkspace = coalesce(allWorkspacesToOpen.map(workspaceToOpen => findWindowOnWorkspaceOrFolder(this.getWindows(), workspaceToOpen.workspace.configPath)));
|
||||
if (windowsOnWorkspace.length > 0) {
|
||||
const windowOnWorkspace = windowsOnWorkspace[0];
|
||||
const filesToOpenInWindow = (filesToOpen?.remoteAuthority === windowOnWorkspace.remoteAuthority) ? filesToOpen : undefined;
|
||||
const filesToOpenInWindow = isEqualAuthority(filesToOpen?.remoteAuthority, windowOnWorkspace.remoteAuthority) ? filesToOpen : undefined;
|
||||
|
||||
// Do open files
|
||||
addUsedWindow(this.doOpenFilesInExistingWindow(openConfig, windowOnWorkspace, filesToOpenInWindow), !!filesToOpenInWindow);
|
||||
|
@ -522,7 +523,7 @@ export class WindowsMainService extends Disposable implements IWindowsMainServic
|
|||
}
|
||||
|
||||
const remoteAuthority = workspaceToOpen.remoteAuthority;
|
||||
const filesToOpenInWindow = (filesToOpen?.remoteAuthority === remoteAuthority) ? filesToOpen : undefined;
|
||||
const filesToOpenInWindow = isEqualAuthority(filesToOpen?.remoteAuthority, remoteAuthority) ? filesToOpen : undefined;
|
||||
|
||||
// Do open folder
|
||||
addUsedWindow(this.doOpenFolderOrWorkspace(openConfig, workspaceToOpen, openFolderInNewWindow, filesToOpenInWindow), !!filesToOpenInWindow);
|
||||
|
@ -539,7 +540,7 @@ export class WindowsMainService extends Disposable implements IWindowsMainServic
|
|||
const windowsOnFolderPath = coalesce(allFoldersToOpen.map(folderToOpen => findWindowOnWorkspaceOrFolder(this.getWindows(), folderToOpen.workspace.uri)));
|
||||
if (windowsOnFolderPath.length > 0) {
|
||||
const windowOnFolderPath = windowsOnFolderPath[0];
|
||||
const filesToOpenInWindow = filesToOpen?.remoteAuthority === windowOnFolderPath.remoteAuthority ? filesToOpen : undefined;
|
||||
const filesToOpenInWindow = isEqualAuthority(filesToOpen?.remoteAuthority, windowOnFolderPath.remoteAuthority) ? filesToOpen : undefined;
|
||||
|
||||
// Do open files
|
||||
addUsedWindow(this.doOpenFilesInExistingWindow(openConfig, windowOnFolderPath, filesToOpenInWindow), !!filesToOpenInWindow);
|
||||
|
@ -554,7 +555,7 @@ export class WindowsMainService extends Disposable implements IWindowsMainServic
|
|||
}
|
||||
|
||||
const remoteAuthority = folderToOpen.remoteAuthority;
|
||||
const filesToOpenInWindow = (filesToOpen?.remoteAuthority === remoteAuthority) ? filesToOpen : undefined;
|
||||
const filesToOpenInWindow = isEqualAuthority(filesToOpen?.remoteAuthority, remoteAuthority) ? filesToOpen : undefined;
|
||||
|
||||
// Do open folder
|
||||
addUsedWindow(this.doOpenFolderOrWorkspace(openConfig, folderToOpen, openFolderInNewWindow, filesToOpenInWindow), !!filesToOpenInWindow);
|
||||
|
@ -568,7 +569,7 @@ export class WindowsMainService extends Disposable implements IWindowsMainServic
|
|||
if (allEmptyToRestore.length > 0) {
|
||||
allEmptyToRestore.forEach(emptyWindowBackupInfo => {
|
||||
const remoteAuthority = emptyWindowBackupInfo.remoteAuthority;
|
||||
const filesToOpenInWindow = (filesToOpen?.remoteAuthority === remoteAuthority) ? filesToOpen : undefined;
|
||||
const filesToOpenInWindow = isEqualAuthority(filesToOpen?.remoteAuthority, remoteAuthority) ? filesToOpen : undefined;
|
||||
|
||||
addUsedWindow(this.openInBrowserWindow({
|
||||
userEnv: openConfig.userEnv,
|
||||
|
@ -710,7 +711,7 @@ export class WindowsMainService extends Disposable implements IWindowsMainServic
|
|||
const foldersToOpen = pathsToOpen.filter(path => isSingleFolderWorkspacePathToOpen(path)) as ISingleFolderWorkspacePathToOpen[];
|
||||
if (foldersToOpen.length > 1) {
|
||||
const remoteAuthority = foldersToOpen[0].remoteAuthority;
|
||||
if (foldersToOpen.every(folderToOpen => folderToOpen.remoteAuthority === remoteAuthority)) { // only if all folder have the same authority
|
||||
if (foldersToOpen.every(folderToOpen => isEqualAuthority(folderToOpen.remoteAuthority, remoteAuthority))) { // only if all folder have the same authority
|
||||
const workspace = this.workspacesManagementMainService.createUntitledWorkspaceSync(foldersToOpen.map(folder => ({ uri: folder.workspace.uri })));
|
||||
|
||||
// Add workspace and remove folders thereby
|
||||
|
@ -1410,7 +1411,7 @@ export class WindowsMainService extends Disposable implements IWindowsMainServic
|
|||
}
|
||||
|
||||
private getLastActiveWindowForAuthority(remoteAuthority: string | undefined): ICodeWindow | undefined {
|
||||
return this.doGetLastActiveWindow(this.getWindows().filter(window => window.remoteAuthority === remoteAuthority));
|
||||
return this.doGetLastActiveWindow(this.getWindows().filter(window => isEqualAuthority(window.remoteAuthority, remoteAuthority)));
|
||||
}
|
||||
|
||||
private doGetLastActiveWindow(windows: ICodeWindow[]): ICodeWindow | undefined {
|
||||
|
@ -1460,3 +1461,7 @@ export class WindowsMainService extends Disposable implements IWindowsMainServic
|
|||
return this.getWindowById(browserWindow.id);
|
||||
}
|
||||
}
|
||||
|
||||
function isEqualAuthority(a1: string | undefined, a2: string | undefined) {
|
||||
return a1 === a2 || (a1 !== undefined && a2 !== undefined && equalsIgnoreCase(a1, a2));
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue