提交 376ec063 编写于 作者: M Matt Bierner

Replace strings.repeat

Use standard ''.repeat instead
上级 8b49aa8a
......@@ -820,17 +820,6 @@ export function stripUTF8BOM(str: string): string {
return startsWithUTF8BOM(str) ? str.substr(1) : str;
}
/**
* @deprecated ES6
*/
export function repeat(s: string, count: number): string {
let result = '';
for (let i = 0; i < count; i++) {
result += s;
}
return result;
}
/**
* Checks if the characters of the provided query string are included in the
* target string. The characters do not have to be contiguous within the string.
......
......@@ -183,13 +183,6 @@ suite('Strings', () => {
assert.strictEqual(' '.trim(), '');
});
test('repeat', () => {
assert.strictEqual(strings.repeat(' ', 4), ' ');
assert.strictEqual(strings.repeat(' ', 1), ' ');
assert.strictEqual(strings.repeat(' ', 0), '');
assert.strictEqual(strings.repeat('abc', 2), 'abcabc');
});
test('lastNonWhitespaceIndex', () => {
assert.strictEqual(strings.lastNonWhitespaceIndex('abc \t \t '), 2);
assert.strictEqual(strings.lastNonWhitespaceIndex('abc'), 2);
......
......@@ -7,7 +7,6 @@ import * as DOM from 'vs/base/browser/dom';
import { Action } from 'vs/base/common/actions';
import { createKeybinding, ResolvedKeybinding } from 'vs/base/common/keyCodes';
import { isWindows, OS } from 'vs/base/common/platform';
import { repeat } from 'vs/base/common/strings';
import * as nls from 'vs/nls';
import { IClipboardService } from 'vs/platform/clipboard/common/clipboardService';
import { ILabelService } from 'vs/platform/label/common/label';
......@@ -804,8 +803,8 @@ function matchToString(match: Match, indent = 0): string {
getFirstLinePrefix() :
getOtherLinePrefix(i);
const paddingStr = repeat(' ', largestPrefixSize - prefix.length);
const indentStr = repeat(' ', indent);
const paddingStr = ' '.repeat(largestPrefixSize - prefix.length);
const indentStr = ' '.repeat(indent);
return `${indentStr}${prefix}: ${paddingStr}${line}`;
});
......
......@@ -4,7 +4,6 @@
*--------------------------------------------------------------------------------------------*/
import { coalesce, flatten } from 'vs/base/common/arrays';
import { repeat } from 'vs/base/common/strings';
import { URI } from 'vs/base/common/uri';
import 'vs/css!./media/searchEditor';
import { ServicesAccessor } from 'vs/editor/browser/editorExtensions';
......@@ -35,7 +34,7 @@ const matchToSearchResultFormat = (match: Match, longestLineNumber: number): { l
fullMatchLines
.forEach((sourceLine, i) => {
const lineNumber = getLinePrefix(i);
const paddingStr = repeat(' ', longestLineNumber - lineNumber.length);
const paddingStr = ' '.repeat(longestLineNumber - lineNumber.length);
const prefix = ` ${paddingStr}${lineNumber}: `;
const prefixOffset = prefix.length;
......@@ -85,7 +84,7 @@ function fileMatchToSearchResultFormat(fileMatch: FileMatch, labelFormatter: (x:
if (lastLine !== undefined && lineNumber !== lastLine + 1) {
text.push('');
}
text.push(` ${repeat(' ', longestLineNumber - `${lineNumber}`.length)}${lineNumber} ${line}`);
text.push(` ${' '.repeat(longestLineNumber - `${lineNumber}`.length)}${lineNumber} ${line}`);
lastLine = lineNumber;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册