當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript paths.isEqual函數代碼示例

本文整理匯總了TypeScript中vs/base/common/paths.isEqual函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript isEqual函數的具體用法?TypeScript isEqual怎麽用?TypeScript isEqual使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了isEqual函數的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1:

	return windows.filter(window => {

		// check for workspace config path
		if (window.openedWorkspace && paths.isEqual(window.openedWorkspace.configPath, path, !platform.isLinux /* ignorecase */)) {
			return true;
		}

		// check for folder path
		if (window.openedFolderPath && paths.isEqual(window.openedFolderPath, path, !platform.isLinux /* ignorecase */)) {
			return true;
		}

		return false;
	})[0];
開發者ID:armanio123,項目名稱:vscode,代碼行數:14,代碼來源:windowsFinder.ts

示例2:

		const res = windows.filter(w => {

			// match on extension development path
			if (typeof extensionDevelopmentPath === 'string' && paths.isEqual(w.extensionDevelopmentPath, extensionDevelopmentPath, !platform.isLinux /* ignorecase */)) {
				return true;
			}

			return false;
		});
開發者ID:naturtle,項目名稱:vscode,代碼行數:9,代碼來源:windowsFinder.ts

示例3:

export function findWindowOnExtensionDevelopmentPath<W extends ISimpleWindow>(windows: W[], extensionDevelopmentPath: string): W | null {
	for (const window of windows) {
		// match on extension development path. The path can be a path or uri string, using paths.isEqual is not 100% correct but good enough
		if (window.extensionDevelopmentPath && paths.isEqual(window.extensionDevelopmentPath, extensionDevelopmentPath, !platform.isLinux /* ignorecase */)) {
			return window;
		}
	}
	return null;
}
開發者ID:VishalMadhvani,項目名稱:vscode,代碼行數:9,代碼來源:windowsFinder.ts

示例4: getPathLabel

export function getPathLabel(resource: URI | string, rootProvider?: IWorkspaceFolderProvider, userHomeProvider?: IUserHomeProvider): string {
	if (!resource) {
		return null;
	}

	if (typeof resource === 'string') {
		resource = URI.file(resource);
	}

	if (resource.scheme !== 'file' && resource.scheme !== 'untitled') {
		return resource.with({ query: null, fragment: null }).toString(true);
	}

	// 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.fsPath, resource.fsPath, !platform.isLinux /* ignorecase */)) {
			pathLabel = ''; // no label if pathes are identical
		} else {
			pathLabel = normalize(ltrim(resource.fsPath.substr(baseResource.uri.fsPath.length), nativeSep), true);
		}

		if (hasMultipleRoots) {
			const rootName = pathsBasename(baseResource.uri.fsPath);
			pathLabel = pathLabel ? join(rootName, pathLabel) : rootName; // always show root basename if there are multiple
		}

		return pathLabel;
	}

	// 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 (!platform.isWindows && userHomeProvider) {
		res = tildify(res, userHomeProvider.userHome);
	}

	return res;
}
開發者ID:JarnoNijboer,項目名稱:vscode,代碼行數:46,代碼來源:labels.ts

示例5: getPathLabel

export function getPathLabel(resource: URI | string, rootProvider?: IRootProvider, userHomeProvider?: IUserHomeProvider): 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.getRoot(resource) : null;
	if (baseResource) {
		const hasMultipleRoots = rootProvider.getWorkspace().roots.length > 1;

		let pathLabel: string;
		if (isEqual(baseResource.fsPath, resource.fsPath, !platform.isLinux /* ignorecase */)) {
			pathLabel = ''; // no label if pathes are identical
		} else {
			pathLabel = normalize(ltrim(resource.fsPath.substr(baseResource.fsPath.length), nativeSep), true);
		}

		if (hasMultipleRoots) {
			const rootName = basename(baseResource.fsPath);
			pathLabel = pathLabel ? join(rootName, pathLabel) : rootName; // always show root basename if there are multiple
		}

		return pathLabel;
	}

	// convert c:\something => C:\something
	if (platform.isWindows && resource.fsPath && resource.fsPath[1] === ':') {
		return normalize(resource.fsPath.charAt(0).toUpperCase() + resource.fsPath.slice(1), true);
	}

	// normalize and tildify (macOS, Linux only)
	let res = normalize(resource.fsPath, true);
	if (!platform.isWindows && userHomeProvider) {
		res = tildify(res, userHomeProvider.userHome);
	}

	return res;
}
開發者ID:Chan-PH,項目名稱:vscode,代碼行數:42,代碼來源:labels.ts

示例6: doScoreItem

function doScoreItem(label: string, description: string, path: string, query: IPreparedQuery, fuzzy: boolean): IItemScore {

	// 1.) treat identity matches on full path highest
	if (path && isEqual(query.value, path, true)) {
		return { score: PATH_IDENTITY_SCORE, labelMatch: [{ start: 0, end: label.length }], descriptionMatch: description ? [{ start: 0, end: description.length }] : void 0 };
	}

	// We only consider label matches if the query is not including file path separators
	const preferLabelMatches = !path || !query.containsPathSeparator;
	if (preferLabelMatches) {

		// 2.) treat prefix matches on the label second highest
		const prefixLabelMatch = matchesPrefix(query.value, label);
		if (prefixLabelMatch) {
			return { score: LABEL_PREFIX_SCORE, labelMatch: prefixLabelMatch };
		}

		// 3.) treat camelcase matches on the label third highest
		const camelcaseLabelMatch = matchesCamelCase(query.value, label);
		if (camelcaseLabelMatch) {
			return { score: LABEL_CAMELCASE_SCORE, labelMatch: camelcaseLabelMatch };
		}

		// 4.) prefer scores on the label if any
		const [labelScore, labelPositions] = score(label, query.value, query.lowercase, fuzzy);
		if (labelScore) {
			return { score: labelScore + LABEL_SCORE_THRESHOLD, labelMatch: createMatches(labelPositions) };
		}
	}

	// 5.) finally compute description + label scores if we have a description
	if (description) {
		let descriptionPrefix = description;
		if (!!path) {
			descriptionPrefix = `${description}${nativeSep}`; // assume this is a file path
		}

		const descriptionPrefixLength = descriptionPrefix.length;
		const descriptionAndLabel = `${descriptionPrefix}${label}`;

		const [labelDescriptionScore, labelDescriptionPositions] = score(descriptionAndLabel, query.value, query.lowercase, fuzzy);
		if (labelDescriptionScore) {
			const labelDescriptionMatches = createMatches(labelDescriptionPositions);
			const labelMatch: IMatch[] = [];
			const descriptionMatch: IMatch[] = [];

			// We have to split the matches back onto the label and description portions
			labelDescriptionMatches.forEach(h => {

				// Match overlaps label and description part, we need to split it up
				if (h.start < descriptionPrefixLength && h.end > descriptionPrefixLength) {
					labelMatch.push({ start: 0, end: h.end - descriptionPrefixLength });
					descriptionMatch.push({ start: h.start, end: descriptionPrefixLength });
				}

				// Match on label part
				else if (h.start >= descriptionPrefixLength) {
					labelMatch.push({ start: h.start - descriptionPrefixLength, end: h.end - descriptionPrefixLength });
				}

				// Match on description part
				else {
					descriptionMatch.push(h);
				}
			});

			return { score: labelDescriptionScore, labelMatch, descriptionMatch };
		}
	}

	return NO_ITEM_SCORE;
}
開發者ID:AlexxNica,項目名稱:sqlopsstudio,代碼行數:72,代碼來源:quickOpenScorer.ts

示例7: test

	test('isEqual (ignoreCase)', function () {
		testIsEqual(isEqual);

		// basics (uris)
		assert(isEqual(URI.file('/some/path').fsPath, URI.file('/some/path').fsPath, true));
		assert(isEqual(URI.file('c:\\some\\path').fsPath, URI.file('c:\\some\\path').fsPath, true));

		assert(isEqual(URI.file('/someöäü/path').fsPath, URI.file('/someöäü/path').fsPath, true));
		assert(isEqual(URI.file('c:\\someöäü\\path').fsPath, URI.file('c:\\someöäü\\path').fsPath, true));

		assert(!isEqual(URI.file('/some/path').fsPath, URI.file('/some/other/path').fsPath, true));
		assert(!isEqual(URI.file('c:\\some\\path').fsPath, URI.file('c:\\some\\other\\path').fsPath, true));

		assert(isEqual(URI.file('/some/path').fsPath, URI.file('/some/PATH').fsPath, true));
		assert(isEqual(URI.file('/someöäü/path').fsPath, URI.file('/someÖÄÜ/PATH').fsPath, true));
		assert(isEqual(URI.file('c:\\some\\path').fsPath, URI.file('c:\\some\\PATH').fsPath, true));
		assert(isEqual(URI.file('c:\\someöäü\\path').fsPath, URI.file('c:\\someÖÄÜ\\PATH').fsPath, true));
		assert(isEqual(URI.file('c:\\some\\path').fsPath, URI.file('C:\\some\\PATH').fsPath, true));
	});
開發者ID:burhandodhy,項目名稱:azuredatastudio,代碼行數:19,代碼來源:files.test.ts


注:本文中的vs/base/common/paths.isEqual函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。