未验证 提交 7f4d4525 编写于 作者: J João Moreno

remove strings.pad

related to #103454
上级 e6cf885a
......@@ -3,7 +3,6 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { pad } from './strings';
import { localize } from 'vs/nls';
const minute = 60;
......@@ -121,11 +120,11 @@ export function fromNow(date: number | Date, appendAgoLabel?: boolean): string {
export function toLocalISOString(date: Date): string {
return date.getFullYear() +
'-' + pad(date.getMonth() + 1, 2) +
'-' + pad(date.getDate(), 2) +
'T' + pad(date.getHours(), 2) +
':' + pad(date.getMinutes(), 2) +
':' + pad(date.getSeconds(), 2) +
'-' + String(date.getMonth() + 1).padStart(2, '0') +
'-' + String(date.getDate()).padStart(2, '0') +
'T' + String(date.getHours()).padStart(2, '0') +
':' + String(date.getMinutes()).padStart(2, '0') +
':' + String(date.getSeconds()).padStart(2, '0') +
'.' + (date.getMilliseconds() / 1000).toFixed(3).slice(2, 5) +
'Z';
}
......@@ -13,20 +13,6 @@ export function isFalsyOrWhitespace(str: string | undefined): boolean {
return str.trim().length === 0;
}
/**
* @deprecated ES6: use `String.padStart`
*/
export function pad(n: number, l: number, char: string = '0'): string {
const str = '' + n;
const r = [str];
for (let i = str.length; i < l; i++) {
r.push(char);
}
return r.reverse().join('');
}
const _formatRegexp = /{(\d+)}/g;
/**
......
......@@ -125,13 +125,6 @@ suite('Strings', () => {
assert.strictEqual(strings.lcut('a', 10), 'a');
});
test('pad', () => {
assert.strictEqual(strings.pad(1, 0), '1');
assert.strictEqual(strings.pad(1, 1), '1');
assert.strictEqual(strings.pad(1, 2), '01');
assert.strictEqual(strings.pad(0, 2), '00');
});
test('escape', () => {
assert.strictEqual(strings.escape(''), '');
assert.strictEqual(strings.escape('foo'), 'foo');
......
......@@ -22,7 +22,7 @@ import { IOpenerService } from 'vs/platform/opener/common/opener';
import { editorHoverBackground, editorHoverBorder, textCodeBlockBackground, textLinkForeground, editorHoverForeground } from 'vs/platform/theme/common/colorRegistry';
import { registerThemingParticipant } from 'vs/platform/theme/common/themeService';
import { ParameterHintsModel, TriggerContext } from 'vs/editor/contrib/parameterHints/parameterHintsModel';
import { pad, escapeRegExpCharacters } from 'vs/base/common/strings';
import { escapeRegExpCharacters } from 'vs/base/common/strings';
import { registerIcon, Codicon } from 'vs/base/common/codicons';
import { assertIsDefined } from 'vs/base/common/types';
import { ColorScheme } from 'vs/platform/theme/common/theme';
......@@ -247,7 +247,7 @@ export class ParameterHintsWidget extends Disposable implements IContentWidget {
dom.toggleClass(this.domNodes.docs, 'empty', !hasDocs);
this.domNodes.overloads.textContent =
pad(hints.activeSignature + 1, hints.signatures.length.toString().length) + '/' + hints.signatures.length;
String(hints.activeSignature + 1).padStart(hints.signatures.length.toString().length, '0') + '/' + hints.signatures.length;
if (activeParameter) {
const labelToAnnounce = this.getParameterLabel(signature, activeParameterIndex);
......
......@@ -402,7 +402,7 @@ class RemoteSearchProvider implements ISearchProvider {
const uuid = ext.identifier.uuid;
const versionString = ext.manifest.version
.split('.')
.map(versionPart => strings.pad(<any>versionPart, 10))
.map(versionPart => String(versionPart).padStart(10), '0')
.join('');
return `(packageid eq '${uuid}' and startbuildno le '${versionString}' and endbuildno ge '${versionString}')`;
......
......@@ -6,7 +6,6 @@
import * as errors from 'vs/base/common/errors';
import { Emitter, Event } from 'vs/base/common/event';
import { Disposable, IDisposable } from 'vs/base/common/lifecycle';
import * as strings from 'vs/base/common/strings';
import { IMessagePassingProtocol } from 'vs/base/parts/ipc/common/ipc';
import { IWorkbenchEnvironmentService } from 'vs/workbench/services/environment/common/environmentService';
import { IInstantiationService, ServicesAccessor } from 'vs/platform/instantiation/common/instantiation';
......@@ -344,7 +343,7 @@ class RPCLogger implements IRPCProtocolLogger {
const colorTable = colorTables[initiator];
const color = LOG_USE_COLORS ? colorTable[req % colorTable.length] : '#000000';
let args = [`%c[${direction}]%c[${strings.pad(totalLength, 7, ' ')}]%c[len: ${strings.pad(msgLength, 5, ' ')}]%c${strings.pad(req, 5, ' ')} - ${str}`, 'color: darkgreen', 'color: grey', 'color: grey', `color: ${color}`];
let args = [`%c[${direction}]%c[${String(totalLength).padStart(7)}]%c[len: ${String(msgLength).padStart(5)}]%c${String(req).padStart(5)} - ${str}`, 'color: darkgreen', 'color: grey', 'color: grey', `color: ${color}`];
if (/\($/.test(str)) {
args = args.concat(data);
args.push(')');
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册