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


TypeScript strings.ltrim函數代碼示例

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


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

示例1: matchesFuzzyOcticonAware

export function matchesFuzzyOcticonAware(query: string, target: IParsedOcticons, enableSeparateSubstringMatching = false): IMatch[] | null {
	const { text, octiconOffsets } = target;

	// Return early if there are no octicon markers in the word to match against
	if (!octiconOffsets || octiconOffsets.length === 0) {
		return matchesFuzzy(query, text, enableSeparateSubstringMatching);
	}

	// Trim the word to match against because it could have leading
	// whitespace now if the word started with an octicon
	const wordToMatchAgainstWithoutOcticonsTrimmed = ltrim(text, ' ');
	const leadingWhitespaceOffset = text.length - wordToMatchAgainstWithoutOcticonsTrimmed.length;

	// match on value without octicons
	const matches = matchesFuzzy(query, wordToMatchAgainstWithoutOcticonsTrimmed, enableSeparateSubstringMatching);

	// Map matches back to offsets with octicons and trimming
	if (matches) {
		for (const match of matches) {
			const octiconOffset = octiconOffsets[match.start + leadingWhitespaceOffset] /* octicon offsets at index */ + leadingWhitespaceOffset /* overall leading whitespace offset */;
			match.start += octiconOffset;
			match.end += octiconOffset;
		}
	}

	return matches;
}
開發者ID:PKRoma,項目名稱:vscode,代碼行數:27,代碼來源:octicon.ts

示例2: 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;
}
開發者ID:developers23,項目名稱:vscode,代碼行數:47,代碼來源:labels.ts

示例3: 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.authority + resource.path;
	}

	// 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:servicesgpr,項目名稱:vscode,代碼行數:46,代碼來源:labels.ts

示例4: 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


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