提交 1f1b7781 编写于 作者: M Martin Aeschlimann

resource.isEqual / isEqualOrParent: use isIgnore default bahaviour

上级 758be52a
......@@ -46,7 +46,7 @@ function isEqualAuthority(a1: string, a2: string, ignoreCase?: boolean) {
return a1 === a2 || ignoreCase && a1 && a2 && equalsIgnoreCase(a1, a2);
}
export function isEqual(first: URI, second: URI, ignoreCase?: boolean): boolean {
export function isEqual(first: URI, second: URI, ignoreCase = hasToIgnoreCase(first)): boolean {
const identityEquals = (first === second);
if (identityEquals) {
return true;
......
......@@ -37,7 +37,7 @@ import { normalizeNFC } from 'vs/base/common/normalization';
import URI from 'vs/base/common/uri';
import { Queue } from 'vs/base/common/async';
import { exists } from 'vs/base/node/pfs';
import { getComparisonKey, isEqual, hasToIgnoreCase, normalizePath } from 'vs/base/common/resources';
import { getComparisonKey, isEqual, normalizePath } from 'vs/base/common/resources';
import { endsWith } from 'vs/base/common/strings';
enum WindowError {
......@@ -328,7 +328,7 @@ export class WindowsManager implements IWindowsMainService {
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, hasToIgnoreCase(o.folderUri));
const sameFolder = win.openedFolderUri && o.folderUri && isEqual(o.folderUri, win.openedFolderUri);
if (sameWorkspace || sameFolder) {
o.uiState = state.uiState;
......@@ -444,7 +444,7 @@ export class WindowsManager implements IWindowsMainService {
const usedWindow = usedWindows[i];
if (
(usedWindow.openedWorkspace && workspacesToRestore.some(workspace => workspace.id === usedWindow.openedWorkspace.id)) || // skip over restored workspace
(usedWindow.openedFolderUri && foldersToRestore.some(folder => isEqual(folder, usedWindow.openedFolderUri, hasToIgnoreCase(folder)))) || // skip over restored folder
(usedWindow.openedFolderUri && foldersToRestore.some(folder => isEqual(folder, usedWindow.openedFolderUri))) || // skip over restored folder
(usedWindow.backupPath && emptyToRestore.some(empty => empty === basename(usedWindow.backupPath))) // skip over restored empty window
) {
continue;
......@@ -660,7 +660,7 @@ export class WindowsManager implements IWindowsMainService {
// Open remaining ones
allFoldersToOpen.forEach(folderToOpen => {
if (windowsOnFolderPath.some(win => isEqual(win.openedFolderUri, folderToOpen, hasToIgnoreCase(win.openedFolderUri)))) {
if (windowsOnFolderPath.some(win => isEqual(win.openedFolderUri, folderToOpen))) {
return; // ignore folders that are already open
}
......@@ -1324,7 +1324,7 @@ export class WindowsManager implements IWindowsMainService {
// Known Folder - load from stored settings
if (configuration.folderUri) {
const stateForFolder = this.windowsState.openedWindows.filter(o => o.folderUri && isEqual(o.folderUri, configuration.folderUri, hasToIgnoreCase(o.folderUri))).map(o => o.uiState);
const stateForFolder = this.windowsState.openedWindows.filter(o => o.folderUri && isEqual(o.folderUri, configuration.folderUri)).map(o => o.uiState);
if (stateForFolder.length) {
return stateForFolder[0];
}
......
......@@ -10,7 +10,7 @@ import * as paths from 'vs/base/common/paths';
import { OpenContext } from 'vs/platform/windows/common/windows';
import { IWorkspaceIdentifier, IResolvedWorkspace, ISingleFolderWorkspaceIdentifier, isSingleFolderWorkspaceIdentifier, isWorkspaceIdentifier } from 'vs/platform/workspaces/common/workspaces';
import URI from 'vs/base/common/uri';
import { hasToIgnoreCase, isEqual, isEqualOrParent } from 'vs/base/common/resources';
import { isEqual, isEqualOrParent } from 'vs/base/common/resources';
export interface ISimpleWindow {
openedWorkspace?: IWorkspaceIdentifier;
......@@ -49,13 +49,13 @@ function findWindowOnFilePath<W extends ISimpleWindow>(windows: W[], fileUri: UR
for (let i = 0; i < workspaceWindows.length; i++) {
const window = workspaceWindows[i];
const resolvedWorkspace = workspaceResolver(window.openedWorkspace);
if (resolvedWorkspace && resolvedWorkspace.folders.some(folder => isEqualOrParent(fileUri, folder.uri, hasToIgnoreCase(fileUri)))) {
if (resolvedWorkspace && resolvedWorkspace.folders.some(folder => isEqualOrParent(fileUri, folder.uri))) {
return window;
}
}
// 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, hasToIgnoreCase(fileUri)));
const singleFolderWindowsOnFilePath = windows.filter(window => window.openedFolderUri && isEqualOrParent(fileUri, window.openedFolderUri));
if (singleFolderWindowsOnFilePath.length) {
return singleFolderWindowsOnFilePath.sort((a, b) => -(a.openedFolderUri.path.length - b.openedFolderUri.path.length))[0];
}
......@@ -74,7 +74,7 @@ export function findWindowOnWorkspace<W extends ISimpleWindow>(windows: W[], wor
for (const window of windows) {
// match on folder
if (isSingleFolderWorkspaceIdentifier(workspace)) {
if (window.openedFolderUri && isEqual(window.openedFolderUri, workspace, hasToIgnoreCase(window.openedFolderUri))) {
if (window.openedFolderUri && isEqual(window.openedFolderUri, workspace)) {
return window;
}
}
......@@ -111,7 +111,7 @@ export function findWindowOnWorkspaceOrFolderUri<W extends ISimpleWindow>(window
}
// check for folder path
if (window.openedFolderUri && isEqual(window.openedFolderUri, uri, hasToIgnoreCase(uri))) {
if (window.openedFolderUri && isEqual(window.openedFolderUri, uri)) {
return window;
}
}
......
......@@ -121,7 +121,7 @@ export class BackupMainService implements IBackupMainService {
}
public registerFolderBackupSync(folderUri: URI): string {
if (!this.folderWorkspaces.some(uri => areResourcesEquals(folderUri, uri, hasToIgnoreCase(folderUri)))) {
if (!this.folderWorkspaces.some(uri => areResourcesEquals(folderUri, uri))) {
this.folderWorkspaces.push(folderUri);
this.saveSync();
}
......@@ -129,7 +129,7 @@ export class BackupMainService implements IBackupMainService {
}
public unregisterFolderBackupSync(folderUri: URI): void {
let index = arrays.firstIndex(this.folderWorkspaces, uri => areResourcesEquals(folderUri, uri, hasToIgnoreCase(folderUri)));
let index = arrays.firstIndex(this.folderWorkspaces, uri => areResourcesEquals(folderUri, uri));
if (index !== -1) {
this.folderWorkspaces.splice(index, 1);
this.saveSync();
......
......@@ -19,7 +19,7 @@ import { IHistoryMainService, IRecentlyOpened } from 'vs/platform/history/common
import { IEnvironmentService } from 'vs/platform/environment/common/environment';
import { isEqual } from 'vs/base/common/paths';
import { RunOnceScheduler } from 'vs/base/common/async';
import { getComparisonKey, isEqual as areResourcesEqual, hasToIgnoreCase, dirname } from 'vs/base/common/resources';
import { getComparisonKey, isEqual as areResourcesEqual, dirname } from 'vs/base/common/resources';
import URI, { UriComponents } from 'vs/base/common/uri';
import { Schemas } from 'vs/base/common/network';
import { IUriLabelService } from 'vs/platform/uriLabel/common/uriLabel';
......@@ -129,11 +129,11 @@ export class HistoryMainService implements IHistoryMainService {
return isWorkspaceIdentifier(workspace) && isEqual(pathToRemove.configPath, workspace.configPath, !isLinux /* ignorecase */);
}
if (isSingleFolderWorkspaceIdentifier(pathToRemove)) {
return isSingleFolderWorkspaceIdentifier(workspace) && areResourcesEqual(pathToRemove, workspace, hasToIgnoreCase(pathToRemove));
return isSingleFolderWorkspaceIdentifier(workspace) && areResourcesEqual(pathToRemove, workspace);
}
if (typeof pathToRemove === 'string') {
if (isSingleFolderWorkspaceIdentifier(workspace)) {
return workspace.scheme === Schemas.file && areResourcesEqual(URI.file(pathToRemove), workspace, hasToIgnoreCase(workspace));
return workspace.scheme === Schemas.file && areResourcesEqual(URI.file(pathToRemove), workspace);
}
if (isWorkspaceIdentifier(workspace)) {
return isEqual(pathToRemove, workspace.configPath, !isLinux /* ignorecase */);
......@@ -149,7 +149,7 @@ export class HistoryMainService implements IHistoryMainService {
// Remove file
const pathToRemoveURI = pathToRemove instanceof URI ? pathToRemove : typeof pathToRemove === 'string' ? URI.file(pathToRemove) : null;
if (pathToRemoveURI) {
index = arrays.firstIndex(mru.files, file => areResourcesEqual(file, pathToRemoveURI, hasToIgnoreCase(pathToRemoveURI)));
index = arrays.firstIndex(mru.files, file => areResourcesEqual(file, pathToRemoveURI));
}
if (index >= 0) {
mru.files.splice(index, 1);
......
......@@ -148,7 +148,7 @@ export class FileEditorTracker extends Disposable implements IWorkbenchContribut
// Do NOT close any opened editor that matches the resource path (either equal or being parent) of the
// resource we move to (movedTo). Otherwise we would close a resource that has been renamed to the same
// path but different casing.
if (movedTo && resources.isEqualOrParent(resource, movedTo, resources.hasToIgnoreCase(resource))) {
if (movedTo && resources.isEqualOrParent(resource, movedTo)) {
return;
}
......@@ -156,7 +156,7 @@ export class FileEditorTracker extends Disposable implements IWorkbenchContribut
if (arg1 instanceof FileChangesEvent) {
matches = arg1.contains(resource, FileChangeType.DELETED);
} else {
matches = resources.isEqualOrParent(resource, arg1, resources.hasToIgnoreCase(resource));
matches = resources.isEqualOrParent(resource, arg1);
}
if (!matches) {
......@@ -223,7 +223,7 @@ export class FileEditorTracker extends Disposable implements IWorkbenchContribut
const resource = editor.getResource();
// Update Editor if file (or any parent of the input) got renamed or moved
if (resources.isEqualOrParent(resource, oldResource, resources.hasToIgnoreCase(resource))) {
if (resources.isEqualOrParent(resource, oldResource)) {
let reopenFileResource: URI;
if (oldResource.toString() === resource.toString()) {
reopenFileResource = newResource; // file got moved
......
......@@ -157,7 +157,7 @@ export class ExplorerItem {
// the folder is fully resolved if either it has a list of children or the client requested this by using the resolveTo
// array of resource path to resolve.
stat.isDirectoryResolved = !!raw.children || (!!resolveTo && resolveTo.some((r) => {
return resources.isEqualOrParent(r, stat.resource, resources.hasToIgnoreCase(r));
return resources.isEqualOrParent(r, stat.resource);
}));
// Recurse into children
......
......@@ -36,7 +36,7 @@ import { IBulkEditService } from 'vs/editor/browser/services/bulkEditService';
import { ICommandService } from 'vs/platform/commands/common/commands';
import { IEditorService, ACTIVE_GROUP } from 'vs/workbench/services/editor/common/editorService';
import { IModelService } from 'vs/editor/common/services/modelService';
import { isEqual, hasToIgnoreCase } from 'vs/base/common/resources';
import { isEqual } from 'vs/base/common/resources';
export class ToggleMarkersPanelAction extends TogglePanelAction {
......@@ -297,7 +297,7 @@ export class QuickFixAction extends Action {
this.update();
} else {
modelService.onModelAdded(model => {
if (isEqual(model.uri, marker.resource, hasToIgnoreCase(model.uri))) {
if (isEqual(model.uri, marker.resource)) {
this.update();
}
}, this, this.disposables);
......
......@@ -24,7 +24,7 @@ import { IEditorInput } from 'vs/workbench/common/editor';
import { IWorkspaceContextService, WorkbenchState } from 'vs/platform/workspace/common/workspace';
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
import { isLinux } from 'vs/base/common/platform';
import { isEqual, hasToIgnoreCase } from 'vs/base/common/resources';
import { isEqual } from 'vs/base/common/resources';
const schemaRegistry = Registry.as<JSONContributionRegistry.IJSONContributionRegistry>(JSONContributionRegistry.Extensions.JSONContribution);
......@@ -89,7 +89,7 @@ export class PreferencesContribution implements IWorkbenchContribution {
const state = this.workspaceService.getWorkbenchState();
if (state === WorkbenchState.FOLDER) {
const folders = this.workspaceService.getWorkspace().folders;
if (isEqual(resource, folders[0].toResource(FOLDER_SETTINGS_PATH), hasToIgnoreCase(resource))) {
if (isEqual(resource, folders[0].toResource(FOLDER_SETTINGS_PATH))) {
return { override: this.preferencesService.openWorkspaceSettings(true, options, group) };
}
}
......@@ -98,7 +98,7 @@ export class PreferencesContribution implements IWorkbenchContribution {
else if (state === WorkbenchState.WORKSPACE) {
const folders = this.workspaceService.getWorkspace().folders;
for (let i = 0; i < folders.length; i++) {
if (isEqual(resource, folders[i].toResource(FOLDER_SETTINGS_PATH), hasToIgnoreCase(resource))) {
if (isEqual(resource, folders[i].toResource(FOLDER_SETTINGS_PATH))) {
return { override: this.preferencesService.openFolderSettings(folders[i].uri, true, options, group) };
}
}
......
......@@ -76,7 +76,7 @@ namespace schema {
const extensionLocation = extension.description.extensionLocation;
const snippetLocation = resources.joinPath(extensionLocation, snippet.path);
if (!resources.isEqualOrParent(snippetLocation, extensionLocation, resources.hasToIgnoreCase(snippetLocation))) {
if (!resources.isEqualOrParent(snippetLocation, extensionLocation)) {
extension.collector.error(localize(
'invalid.path.1',
"Expected `contributes.{0}.path` ({1}) to be included inside extension's folder ({2}). This might make the extension non-portable.",
......
......@@ -338,7 +338,7 @@ export class FileServiceBasedFolderConfiguration extends AbstractFolderConfigura
return paths.normalize(relative(this.folderConfigurationPath.fsPath, resource.fsPath));
}
} else {
if (resources.isEqualOrParent(resource, this.folderConfigurationPath, resources.hasToIgnoreCase(resource))) {
if (resources.isEqualOrParent(resource, this.folderConfigurationPath)) {
return paths.normalize(relative(this.folderConfigurationPath.path, resource.path));
}
}
......
......@@ -40,7 +40,7 @@ import { massageFolderPathForWorkspace } from 'vs/platform/workspaces/node/works
import { UserConfiguration } from 'vs/platform/configuration/node/configuration';
import { IJSONSchema, IJSONSchemaMap } from 'vs/base/common/jsonSchema';
import { localize } from 'vs/nls';
import { isEqual, hasToIgnoreCase } from 'vs/base/common/resources';
import { isEqual } from 'vs/base/common/resources';
import { IUriLabelService } from 'vs/platform/uriLabel/common/uriLabel';
export class WorkspaceService extends Disposable implements IWorkspaceConfigurationService, IWorkspaceContextService {
......@@ -133,7 +133,7 @@ export class WorkspaceService extends Disposable implements IWorkspaceConfigurat
public isCurrentWorkspace(workspaceIdentifier: ISingleFolderWorkspaceIdentifier | IWorkspaceIdentifier): boolean {
switch (this.getWorkbenchState()) {
case WorkbenchState.FOLDER:
return isSingleFolderWorkspaceIdentifier(workspaceIdentifier) && isEqual(workspaceIdentifier, this.workspace.folders[0].uri, hasToIgnoreCase(workspaceIdentifier));
return isSingleFolderWorkspaceIdentifier(workspaceIdentifier) && isEqual(workspaceIdentifier, this.workspace.folders[0].uri);
case WorkbenchState.WORKSPACE:
return isWorkspaceIdentifier(workspaceIdentifier) && this.workspace.id === workspaceIdentifier.id;
}
......
......@@ -60,7 +60,7 @@ export class JSONValidationExtensionPoint {
if (strings.startsWith(uri, './')) {
try {
const colorThemeLocation = resources.joinPath(extensionLocation, uri);
if (!resources.isEqualOrParent(colorThemeLocation, extensionLocation, resources.hasToIgnoreCase(colorThemeLocation))) {
if (!resources.isEqualOrParent(colorThemeLocation, extensionLocation)) {
collector.warn(nls.localize('invalid.path.1', "Expected `contributes.{0}.url` ({1}) to be included inside extension's folder ({2}). This might make the extension non-portable.", configurationExtPoint.name, location, extensionLocation.path));
}
} catch (e) {
......
......@@ -313,7 +313,7 @@ export class TextMateService implements ITextMateService {
}
const grammarLocation = resources.joinPath(extensionLocation, syntax.path);
if (!resources.isEqualOrParent(grammarLocation, extensionLocation, resources.hasToIgnoreCase(grammarLocation))) {
if (!resources.isEqualOrParent(grammarLocation, extensionLocation)) {
collector.warn(nls.localize('invalid.path.1', "Expected `contributes.{0}.path` ({1}) to be included inside extension's folder ({2}). This might make the extension non-portable.", grammarsExtPoint.name, grammarLocation.path, extensionLocation.path));
}
......
......@@ -33,7 +33,7 @@ import { INotificationService } from 'vs/platform/notification/common/notificati
import { isLinux } from 'vs/base/common/platform';
import { IDisposable, toDisposable } from 'vs/base/common/lifecycle';
import { ILogService } from 'vs/platform/log/common/log';
import { isEqual, isEqualOrParent, hasToIgnoreCase } from 'vs/base/common/resources';
import { isEqual, isEqualOrParent } from 'vs/base/common/resources';
/**
* The text file editor model listens to changes to its underlying code editor model and saves these changes through the file service back to the disk.
......@@ -795,14 +795,14 @@ export class TextFileEditorModel extends BaseTextEditorModel implements ITextFil
}
// Check for snippets
if (isEqualOrParent(this.resource, URI.file(path.join(this.environmentService.appSettingsHome, 'snippets')), hasToIgnoreCase(this.resource))) {
if (isEqualOrParent(this.resource, URI.file(path.join(this.environmentService.appSettingsHome, 'snippets')))) {
return 'snippets';
}
// Check for workspace settings file
const folders = this.contextService.getWorkspace().folders;
for (let i = 0; i < folders.length; i++) {
if (isEqualOrParent(this.resource, folders[i].toResource('.vscode'), hasToIgnoreCase(this.resource))) {
if (isEqualOrParent(this.resource, folders[i].toResource('.vscode'))) {
const filename = path.basename(this.resource.fsPath);
if (TextFileEditorModel.WHITELIST_WORKSPACE_JSON.indexOf(filename) > -1) {
return `.vscode/${filename}`;
......
......@@ -95,7 +95,7 @@ export class ColorThemeStore {
}
const colorThemeLocation = resources.joinPath(extensionLocation, theme.path);
if (!resources.isEqualOrParent(colorThemeLocation, extensionLocation, resources.hasToIgnoreCase(colorThemeLocation))) {
if (!resources.isEqualOrParent(colorThemeLocation, extensionLocation)) {
collector.warn(nls.localize('invalid.path.1', "Expected `contributes.{0}.path` ({1}) to be included inside extension's folder ({2}). This might make the extension non-portable.", themesExtPoint.name, colorThemeLocation.path, extensionLocation.path));
}
......
......@@ -97,7 +97,7 @@ export class FileIconThemeStore {
}
const iconThemeLocation = resources.joinPath(extensionLocation, iconTheme.path);
if (!resources.isEqualOrParent(iconThemeLocation, extensionLocation, resources.hasToIgnoreCase(iconThemeLocation))) {
if (!resources.isEqualOrParent(iconThemeLocation, extensionLocation)) {
collector.warn(nls.localize('invalid.path.1', "Expected `contributes.{0}.path` ({1}) to be included inside extension's folder ({2}). This might make the extension non-portable.", iconThemeExtPoint.name, iconThemeLocation.path, extensionLocation.path));
}
......
......@@ -26,7 +26,7 @@ import { BackupFileService } from 'vs/workbench/services/backup/node/backupFileS
import { ICommandService } from 'vs/platform/commands/common/commands';
import { distinct } from 'vs/base/common/arrays';
import { isLinux } from 'vs/base/common/platform';
import { isEqual, hasToIgnoreCase } from 'vs/base/common/resources';
import { isEqual } from 'vs/base/common/resources';
import { INotificationService, Severity } from 'vs/platform/notification/common/notification';
export class WorkspaceEditingService implements IWorkspaceEditingService {
......@@ -138,7 +138,7 @@ export class WorkspaceEditingService implements IWorkspaceEditingService {
private includesSingleFolderWorkspace(folders: URI[]): boolean {
if (this.contextService.getWorkbenchState() === WorkbenchState.FOLDER) {
const workspaceFolder = this.contextService.getWorkspace().folders[0];
return (folders.some(folder => isEqual(folder, workspaceFolder.uri, hasToIgnoreCase(folder))));
return (folders.some(folder => isEqual(folder, workspaceFolder.uri)));
}
return false;
......
......@@ -150,7 +150,7 @@ export class TestContextService implements IWorkspaceContextService {
public isInsideWorkspace(resource: URI): boolean {
if (resource && this.workspace) {
return resources.isEqualOrParent(resource, this.workspace.folders[0].uri, resources.hasToIgnoreCase(resource));
return resources.isEqualOrParent(resource, this.workspace.folders[0].uri);
}
return false;
......@@ -161,7 +161,7 @@ export class TestContextService implements IWorkspaceContextService {
}
public isCurrentWorkspace(workspaceIdentifier: ISingleFolderWorkspaceIdentifier | IWorkspaceIdentifier): boolean {
return isSingleFolderWorkspaceIdentifier(workspaceIdentifier) && resources.isEqual(this.workspace.folders[0].uri, workspaceIdentifier, resources.hasToIgnoreCase(workspaceIdentifier));
return isSingleFolderWorkspaceIdentifier(workspaceIdentifier) && resources.isEqual(this.workspace.folders[0].uri, workspaceIdentifier);
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册