本文整理匯總了TypeScript中vs/base/common/normalization.normalizeNFC函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript normalizeNFC函數的具體用法?TypeScript normalizeNFC怎麽用?TypeScript normalizeNFC使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了normalizeNFC函數的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: done
this.collectStdout(cmd, 'utf8', useRipgrep, onMessage, (err: Error, stdout?: string, last?: boolean) => {
if (err) {
done(err);
return;
}
if (this.isLimitHit) {
done();
return;
}
// Mac: uses NFD unicode form on disk, but we want NFC
const normalized = leftover + (isMac ? normalization.normalizeNFC(stdout) : stdout);
const relativeFiles = normalized.split(useRipgrep ? '\n' : '\n./');
if (!useRipgrep && first && normalized.length >= 2) {
first = false;
relativeFiles[0] = relativeFiles[0].trim().substr(2);
}
if (last) {
const n = relativeFiles.length;
relativeFiles[n - 1] = relativeFiles[n - 1].trim();
if (!relativeFiles[n - 1]) {
relativeFiles.pop();
}
} else {
leftover = relativeFiles.pop();
}
if (relativeFiles.length && relativeFiles[0].indexOf('\n') !== -1) {
done(new Error('Splitting up files failed'));
return;
}
this.cmdResultCount += relativeFiles.length;
if (useRipgrep && noSiblingsClauses) {
for (const relativePath of relativeFiles) {
const basename = path.basename(relativePath);
this.matchFile(onResult, { base: rootFolder, relativePath, basename });
if (this.isLimitHit) {
killCmd();
break;
}
}
if (last || this.isLimitHit) {
done();
}
return;
}
// TODO: Optimize siblings clauses with ripgrep here.
this.addDirectoryEntries(tree, rootFolder, relativeFiles, onResult);
if (last) {
this.matchDirectoryTree(tree, rootFolder, onResult);
done();
}
});
示例2: normalizeNFC
return children.map(child => normalizeNFC(child));
示例3: normalizeNFC
watcher.on('change', (type, raw) => {
if (disposed) {
return; // ignore if already disposed
}
// Normalize file name
let changedFileName: string = '';
if (raw) { // https://github.com/Microsoft/vscode/issues/38191
changedFileName = raw.toString();
if (isMacintosh) {
// Mac: uses NFD unicode form on disk, but we want NFC
// See also https://github.com/nodejs/node/issues/2165
changedFileName = normalizeNFC(changedFileName);
}
}
if (!changedFileName || (type !== 'change' && type !== 'rename')) {
return; // ignore unexpected events
}
// File path: use path directly for files and join with changed file name otherwise
const changedFilePath = file.isDirectory ? join(file.path, changedFileName) : file.path;
// File
if (!file.isDirectory) {
if (type === 'rename' || changedFileName !== originalFileName) {
// The file was either deleted or renamed. Many tools apply changes to files in an
// atomic way ("Atomic Save") by first renaming the file to a temporary name and then
// renaming it back to the original name. Our watcher will detect this as a rename
// and then stops to work on Mac and Linux because the watcher is applied to the
// inode and not the name. The fix is to detect this case and trying to watch the file
// again after a certain delay.
// In addition, we send out a delete event if after a timeout we detect that the file
// does indeed not exist anymore.
const timeoutHandle = setTimeout(async () => {
const fileExists = await exists(changedFilePath);
if (disposed) {
return; // ignore if disposed by now
}
// File still exists, so emit as change event and reapply the watcher
if (fileExists) {
onChange('changed', changedFilePath);
watcherDisposables = [doWatchNonRecursive(file, onChange, onError)];
}
// File seems to be really gone, so emit a deleted event
else {
onChange('deleted', changedFilePath);
}
}, CHANGE_BUFFER_DELAY);
// Very important to dispose the watcher which now points to a stale inode
// and wire in a new disposable that tracks our timeout that is installed
dispose(watcherDisposables);
watcherDisposables = [toDisposable(() => clearTimeout(timeoutHandle))];
} else {
onChange('changed', changedFilePath);
}
}
// Folder
else {
// Children add/delete
if (type === 'rename') {
// Cancel any previous stats for this file path if existing
const statDisposable = mapPathToStatDisposable.get(changedFilePath);
if (statDisposable) {
dispose(statDisposable);
}
// Wait a bit and try see if the file still exists on disk to decide on the resulting event
const timeoutHandle = setTimeout(async () => {
mapPathToStatDisposable.delete(changedFilePath);
const fileExists = await exists(changedFilePath);
if (disposed) {
return; // ignore if disposed by now
}
// Figure out the correct event type:
// File Exists: either 'added' or 'changed' if known before
// File Does not Exist: always 'deleted'
let type: 'added' | 'deleted' | 'changed';
if (fileExists) {
if (folderChildren.has(changedFileName)) {
type = 'changed';
} else {
type = 'added';
folderChildren.add(changedFileName);
}
} else {
folderChildren.delete(changedFileName);
type = 'deleted';
//.........這裏部分代碼省略.........