本文整理匯總了TypeScript中vs/base/common/resources.isEqual函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript isEqual函數的具體用法?TypeScript isEqual怎麽用?TypeScript isEqual使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了isEqual函數的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1:
return windows.filter(window => {
// check for workspace config path
if (window.openedWorkspace && isEqual(URI.file(window.openedWorkspace.configPath), uri, !platform.isLinux /* ignorecase */)) {
return true;
}
// check for folder path
if (window.openedFolderUri && isEqual(window.openedFolderUri, uri, hasToIgnoreCase(uri))) {
return true;
}
return false;
})[0];
示例2:
export function findWindowOnWorkspaceOrFolderUri<W extends ISimpleWindow>(windows: W[], uri: URI): W | null {
if (!uri) {
return null;
}
for (const window of windows) {
// check for workspace config path
if (window.openedWorkspace && isEqual(URI.file(window.openedWorkspace.configPath), uri, !platform.isLinux /* ignorecase */)) {
return window;
}
// check for folder path
if (window.openedFolderUri && isEqual(window.openedFolderUri, uri)) {
return window;
}
}
return null;
}
示例3:
export function findWindowOnWorkspaceOrFolderUri<W extends ISimpleWindow>(windows: W[], uri: URI | undefined): W | null {
if (!uri) {
return null;
}
for (const window of windows) {
// check for workspace config path
if (window.openedWorkspace && isEqual(window.openedWorkspace.configPath, uri)) {
return window;
}
// check for folder path
if (window.openedFolderUri && isEqual(window.openedFolderUri, uri)) {
return window;
}
}
return null;
}
示例4: isEqualOrParent
return this._changes.some(change => {
if (change.type !== type) {
return false;
}
// For deleted also return true when deleted folder is parent of target path
if (type === FileChangeType.DELETED) {
return isEqualOrParent(resource, change.resource, !isLinux /* ignorecase */);
}
return isEqual(resource, change.resource, !isLinux /* ignorecase */);
});
示例5: getPathLabel
export function getPathLabel(resource: URI | string, userHomeProvider: IUserHomeProvider, rootProvider?: IWorkspaceFolderProvider): string {
if (!resource) {
return null;
}
if (typeof resource === 'string') {
resource = URI.file(resource);
}
// return early if we can resolve a relative path label from the root
const baseResource = rootProvider ? rootProvider.getWorkspaceFolder(resource) : null;
if (baseResource) {
const hasMultipleRoots = rootProvider.getWorkspace().folders.length > 1;
let pathLabel: string;
if (isEqual(baseResource.uri, resource, !isLinux)) {
pathLabel = ''; // no label if paths are identical
} else {
pathLabel = normalize(ltrim(resource.path.substr(baseResource.uri.path.length), sep), true);
}
if (hasMultipleRoots) {
const rootName = (baseResource && baseResource.name) ? baseResource.name : pathsBasename(baseResource.uri.fsPath);
pathLabel = pathLabel ? (rootName + ' ⢠' + pathLabel) : rootName; // always show root basename if there are multiple
}
return pathLabel;
}
// return if the resource is neither file:// nor untitled:// and no baseResource was provided
if (resource.scheme !== Schemas.file && resource.scheme !== Schemas.untitled) {
return resource.with({ query: null, fragment: null }).toString(true);
}
// convert c:\something => C:\something
if (hasDriveLetter(resource.fsPath)) {
return normalize(normalizeDriveLetter(resource.fsPath), true);
}
// normalize and tildify (macOS, Linux only)
let res = normalize(resource.fsPath, true);
if (!isWindows && userHomeProvider) {
res = tildify(res, userHomeProvider.userHome);
}
return res;
}
示例6: if
export function findWindowOnWorkspace<W extends ISimpleWindow>(windows: W[], workspace: (IWorkspaceIdentifier | ISingleFolderWorkspaceIdentifier)): W | null {
if (isSingleFolderWorkspaceIdentifier(workspace)) {
for (const window of windows) {
// match on folder
if (isSingleFolderWorkspaceIdentifier(workspace)) {
if (window.openedFolderUri && isEqual(window.openedFolderUri, workspace)) {
return window;
}
}
}
} else if (isWorkspaceIdentifier(workspace)) {
for (const window of windows) {
// match on workspace
if (window.openedWorkspace && window.openedWorkspace.id === workspace.id) {
return window;
}
}
}
return null;
}
示例7: test
test('isEqual', () => {
let fileURI = isWindows ? URI.file('c:\\foo\\bar') : URI.file('/foo/bar');
let fileURI2 = isWindows ? URI.file('C:\\foo\\Bar') : URI.file('/foo/Bar');
assert.equal(isEqual(fileURI, fileURI, true), true);
assert.equal(isEqual(fileURI, fileURI, false), true);
assert.equal(isEqual(fileURI, fileURI, hasToIgnoreCase(fileURI)), true);
assert.equal(isEqual(fileURI, fileURI2, true), true);
assert.equal(isEqual(fileURI, fileURI2, false), false);
let fileURI3 = URI.parse('foo://server:453/foo/bar');
let fileURI4 = URI.parse('foo://server:453/foo/Bar');
assert.equal(isEqual(fileURI3, fileURI3, true), true);
assert.equal(isEqual(fileURI3, fileURI3, false), true);
assert.equal(isEqual(fileURI3, fileURI3, hasToIgnoreCase(fileURI3)), true);
assert.equal(isEqual(fileURI3, fileURI4, true), true);
assert.equal(isEqual(fileURI3, fileURI4, false), false);
assert.equal(isEqual(fileURI, fileURI3, true), false);
});
示例8: assertEqualURI
function assertEqualURI(actual: URI, expected: URI, message?: string) {
if (!isEqual(expected, actual)) {
assert.equal(expected.toString(), actual.toString(), message);
}
}