提交 6e9996ed 编写于 作者: B Benjamin Pasero

Intl is not defined in Safari < 10

上级 7ecae478
......@@ -7,10 +7,41 @@
import scorer = require('vs/base/common/scorer');
import strings = require('vs/base/common/strings');
const FileNameComparer = new Intl.Collator(undefined, { numeric: true, sensitivity: 'base' });
let intlFileNameComparer: Intl.Collator;
export function setFileNameComparer(collator: Intl.Collator): void {
intlFileNameComparer = collator;
}
export function compareFileNames(one: string, other: string): number {
return FileNameComparer.compare(one || '', other || '');
if (intlFileNameComparer) {
return intlFileNameComparer.compare(one || '', other || '');
}
return noIntlCompareFileNames(one, other);
}
const FileNameMatch = /^([^.]*)(\.(.*))?$/;
export function noIntlCompareFileNames(one: string, other: string): number {
let oneMatch = FileNameMatch.exec(one.toLowerCase());
let otherMatch = FileNameMatch.exec(other.toLowerCase());
let oneName = oneMatch[1] || '';
let oneExtension = oneMatch[3] || '';
let otherName = otherMatch[1] || '';
let otherExtension = otherMatch[3] || '';
if (oneName !== otherName) {
return oneName < otherName ? -1 : 1;
}
if (oneExtension === otherExtension) {
return 0;
}
return oneExtension < otherExtension ? -1 : 1;
}
export function compareAnything(one: string, other: string, lookFor: string): number {
......
......@@ -12,6 +12,7 @@ import { IOptions } from 'vs/workbench/common/options';
import * as browser from 'vs/base/browser/browser';
import { domContentLoaded } from 'vs/base/browser/dom';
import errors = require('vs/base/common/errors');
import comparer = require('vs/base/common/comparers');
import platform = require('vs/base/common/platform');
import paths = require('vs/base/common/paths');
import uri from 'vs/base/common/uri';
......@@ -46,11 +47,15 @@ export interface IWindowConfiguration extends ParsedArgs, IOpenFileRequest {
}
export function startup(configuration: IWindowConfiguration): TPromise<void> {
// Ensure others can listen to zoom level changes
browser.setZoomFactor(webFrame.getZoomFactor());
browser.setZoomLevel(webFrame.getZoomLevel());
browser.setFullscreen(!!configuration.fullscreen);
// Setup Intl
comparer.setFileNameComparer(new Intl.Collator(undefined, { numeric: true, sensitivity: 'base' }));
// Shell Options
const filesToOpen = configuration.filesToOpen && configuration.filesToOpen.length ? toInputs(configuration.filesToOpen) : null;
const filesToCreate = configuration.filesToCreate && configuration.filesToCreate.length ? toInputs(configuration.filesToCreate) : null;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册