Skip to content

Commit 91e21b5

Browse files
committed
let -> const, search
1 parent 635b397 commit 91e21b5

13 files changed

Lines changed: 48 additions & 48 deletions

File tree

src/vs/editor/test/common/model/benchmark/searchNReplace.benchmark.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,30 +7,30 @@ import { ITextBufferBuilder } from 'vs/editor/common/model';
77
import { BenchmarkSuite } from 'vs/editor/test/common/model/benchmark/benchmarkUtils';
88
import { generateRandomChunkWithLF, generateRandomReplaces } from 'vs/editor/test/common/model/linesTextBuffer/textBufferAutoTestUtils';
99

10-
let fileSizes = [1, 1000, 64 * 1000, 32 * 1000 * 1000];
10+
const fileSizes = [1, 1000, 64 * 1000, 32 * 1000 * 1000];
1111

12-
for (let fileSize of fileSizes) {
13-
let chunks: string[] = [];
12+
for (const fileSize of fileSizes) {
13+
const chunks: string[] = [];
1414

15-
let chunkCnt = Math.floor(fileSize / (64 * 1000));
15+
const chunkCnt = Math.floor(fileSize / (64 * 1000));
1616
if (chunkCnt === 0) {
1717
chunks.push(generateRandomChunkWithLF(fileSize, fileSize));
1818
} else {
19-
let chunk = generateRandomChunkWithLF(64 * 1000, 64 * 1000);
19+
const chunk = generateRandomChunkWithLF(64 * 1000, 64 * 1000);
2020
// try to avoid OOM
2121
for (let j = 0; j < chunkCnt; j++) {
2222
chunks.push(Buffer.from(chunk + j).toString());
2323
}
2424
}
2525

26-
let replaceSuite = new BenchmarkSuite({
26+
const replaceSuite = new BenchmarkSuite({
2727
name: `File Size: ${fileSize}Byte`,
2828
iterations: 10
2929
});
3030

31-
let edits = generateRandomReplaces(chunks, 500, 5, 10);
31+
const edits = generateRandomReplaces(chunks, 500, 5, 10);
3232

33-
for (let i of [10, 100, 500]) {
33+
for (const i of [10, 100, 500]) {
3434
replaceSuite.add({
3535
name: `replace ${i} occurrences`,
3636
buildBuffer: (textBufferBuilder: ITextBufferBuilder) => {

src/vs/workbench/contrib/search/browser/searchView.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -798,7 +798,7 @@ export class SearchView extends ViewPane {
798798
}
799799
}
800800

801-
let navigator = this.tree.navigate(selected);
801+
const navigator = this.tree.navigate(selected);
802802

803803
let next = navigator.next();
804804
if (!next) {
@@ -1722,7 +1722,7 @@ export class SearchView extends ViewPane {
17221722
const selections = fileMatch.matches().map(m => new Selection(m.range().startLineNumber, m.range().startColumn, m.range().endLineNumber, m.range().endColumn));
17231723
const codeEditor = getCodeEditor(editor.getControl());
17241724
if (codeEditor) {
1725-
let multiCursorController = MultiCursorSelectionController.get(codeEditor);
1725+
const multiCursorController = MultiCursorSelectionController.get(codeEditor);
17261726
multiCursorController.selectAllUsingSelections(selections);
17271727
}
17281728
}

src/vs/workbench/contrib/search/common/searchModel.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -605,7 +605,7 @@ export class FolderMatch extends Disposable {
605605
fileMatches = [fileMatches];
606606
}
607607

608-
for (let match of fileMatches as FileMatch[]) {
608+
for (const match of fileMatches as FileMatch[]) {
609609
this._fileMatches.delete(match.resource);
610610
if (dispose) {
611611
match.dispose();

src/vs/workbench/contrib/search/test/browser/searchViewlet.test.ts

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ suite('Search - Viewlet', () => {
2828
});
2929

3030
test('Data Source', function () {
31-
let result: SearchResult = instantiation.createInstance(SearchResult, null);
31+
const result: SearchResult = instantiation.createInstance(SearchResult, null);
3232
result.query = {
3333
type: QueryType.Text,
3434
contentPattern: { pattern: 'foo' },
@@ -58,20 +58,20 @@ suite('Search - Viewlet', () => {
5858
}]
5959
}]);
6060

61-
let fileMatch = result.matches()[0];
62-
let lineMatch = fileMatch.matches()[0];
61+
const fileMatch = result.matches()[0];
62+
const lineMatch = fileMatch.matches()[0];
6363

6464
assert.equal(fileMatch.id(), 'file:///c%3A/foo');
6565
assert.equal(lineMatch.id(), 'file:///c%3A/foo>[2,1 -> 2,2]b');
6666
});
6767

6868
test('Comparer', () => {
69-
let fileMatch1 = aFileMatch(isWindows ? 'C:\\foo' : '/c/foo');
70-
let fileMatch2 = aFileMatch(isWindows ? 'C:\\with\\path' : '/c/with/path');
71-
let fileMatch3 = aFileMatch(isWindows ? 'C:\\with\\path\\foo' : '/c/with/path/foo');
72-
let lineMatch1 = new Match(fileMatch1, ['bar'], new OneLineRange(0, 1, 1), new OneLineRange(0, 1, 1));
73-
let lineMatch2 = new Match(fileMatch1, ['bar'], new OneLineRange(0, 1, 1), new OneLineRange(2, 1, 1));
74-
let lineMatch3 = new Match(fileMatch1, ['bar'], new OneLineRange(0, 1, 1), new OneLineRange(2, 1, 1));
69+
const fileMatch1 = aFileMatch(isWindows ? 'C:\\foo' : '/c/foo');
70+
const fileMatch2 = aFileMatch(isWindows ? 'C:\\with\\path' : '/c/with/path');
71+
const fileMatch3 = aFileMatch(isWindows ? 'C:\\with\\path\\foo' : '/c/with/path/foo');
72+
const lineMatch1 = new Match(fileMatch1, ['bar'], new OneLineRange(0, 1, 1), new OneLineRange(0, 1, 1));
73+
const lineMatch2 = new Match(fileMatch1, ['bar'], new OneLineRange(0, 1, 1), new OneLineRange(2, 1, 1));
74+
const lineMatch3 = new Match(fileMatch1, ['bar'], new OneLineRange(0, 1, 1), new OneLineRange(2, 1, 1));
7575

7676
assert(searchMatchComparer(fileMatch1, fileMatch2) < 0);
7777
assert(searchMatchComparer(fileMatch2, fileMatch1) > 0);
@@ -84,10 +84,10 @@ suite('Search - Viewlet', () => {
8484
});
8585

8686
test('Advanced Comparer', () => {
87-
let fileMatch1 = aFileMatch(isWindows ? 'C:\\with\\path\\foo10' : '/c/with/path/foo10');
88-
let fileMatch2 = aFileMatch(isWindows ? 'C:\\with\\path2\\foo1' : '/c/with/path2/foo1');
89-
let fileMatch3 = aFileMatch(isWindows ? 'C:\\with\\path2\\bar.a' : '/c/with/path2/bar.a');
90-
let fileMatch4 = aFileMatch(isWindows ? 'C:\\with\\path2\\bar.b' : '/c/with/path2/bar.b');
87+
const fileMatch1 = aFileMatch(isWindows ? 'C:\\with\\path\\foo10' : '/c/with/path/foo10');
88+
const fileMatch2 = aFileMatch(isWindows ? 'C:\\with\\path2\\foo1' : '/c/with/path2/foo1');
89+
const fileMatch3 = aFileMatch(isWindows ? 'C:\\with\\path2\\bar.a' : '/c/with/path2/bar.a');
90+
const fileMatch4 = aFileMatch(isWindows ? 'C:\\with\\path2\\bar.b' : '/c/with/path2/bar.b');
9191

9292
// By default, path < path2
9393
assert(searchMatchComparer(fileMatch1, fileMatch2) < 0);
@@ -98,7 +98,7 @@ suite('Search - Viewlet', () => {
9898
});
9999

100100
function aFileMatch(path: string, searchResult?: SearchResult, ...lineMatches: ITextSearchMatch[]): FileMatch {
101-
let rawMatch: IFileMatch = {
101+
const rawMatch: IFileMatch = {
102102
resource: uri.file(path),
103103
results: lineMatches
104104
};

src/vs/workbench/contrib/search/test/common/extractRange.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,15 +36,15 @@ suite('extractRangeFromFilter', () => {
3636
});
3737

3838
test('allow space after path', async function () {
39-
let res = extractRangeFromFilter('/some/path/file.txt (19,20)');
39+
const res = extractRangeFromFilter('/some/path/file.txt (19,20)');
4040

4141
assert.equal(res?.filter, '/some/path/file.txt');
4242
assert.equal(res?.range.startLineNumber, 19);
4343
assert.equal(res?.range.startColumn, 20);
4444
});
4545

4646
test('unless', async function () {
47-
let res = extractRangeFromFilter('/some/path/file.txt@ (19,20)', ['@']);
47+
const res = extractRangeFromFilter('/some/path/file.txt@ (19,20)', ['@']);
4848

4949
assert.ok(!res);
5050
});

src/vs/workbench/contrib/searchEditor/browser/searchEditor.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -389,7 +389,7 @@ export class SearchEditor extends BaseTextEditor {
389389
const matchText = model.getValueInRange(matchRange);
390390
let file = '';
391391
for (let line = matchRange.startLineNumber; line >= 1; line--) {
392-
let lineText = model.getValueInRange(new Range(line, 1, line, 2));
392+
const lineText = model.getValueInRange(new Range(line, 1, line, 2));
393393
if (lineText !== ' ') { file = model.getLineContent(line); break; }
394394
}
395395
alert(localize('searchResultItem', "Matched {0} at {1} in file {2}", matchText, matchLineText, file.slice(0, file.length - 1)));

src/vs/workbench/contrib/searchEditor/browser/searchEditorInput.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,7 @@ export const getOrMakeSearchEditorInput = (
305305
const priorConfig: SearchConfiguration = reuseOldSettings ? new Memento(SearchEditorInput.ID, storageService).getMemento(StorageScope.WORKSPACE).searchConfig : {};
306306
const defaultConfig = defaultSearchConfig();
307307

308-
let config = { ...defaultConfig, ...priorConfig, ...existingData.config };
308+
const config = { ...defaultConfig, ...priorConfig, ...existingData.config };
309309

310310
if (defaultNumberOfContextLines !== null && defaultNumberOfContextLines !== undefined) {
311311
config.contextLines = existingData.config.contextLines ?? defaultNumberOfContextLines;

src/vs/workbench/contrib/searchEditor/browser/searchEditorSerialization.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,8 @@ function fileMatchToSearchResultFormat(fileMatch: FileMatch, labelFormatter: (x:
6666
const serializedMatches = flatten(sortedMatches.map(match => matchToSearchResultFormat(match, longestLineNumber)));
6767

6868
const uriString = labelFormatter(fileMatch.resource);
69-
let text: string[] = [`${uriString}:`];
70-
let matchRanges: Range[] = [];
69+
const text: string[] = [`${uriString}:`];
70+
const matchRanges: Range[] = [];
7171

7272
const targetLineNumberToOffset: Record<string, number> = {};
7373

@@ -236,8 +236,8 @@ export const serializeSearchResultForEditor =
236236
};
237237

238238
const flattenSearchResultSerializations = (serializations: SearchResultSerialization[]): SearchResultSerialization => {
239-
let text: string[] = [];
240-
let matchRanges: Range[] = [];
239+
const text: string[] = [];
240+
const matchRanges: Range[] = [];
241241

242242
serializations.forEach(serialized => {
243243
serialized.matchRanges.map(translateRangeLines(text.length)).forEach(range => matchRanges.push(range));

src/vs/workbench/services/search/common/replace.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,13 +57,13 @@ export class ReplacePattern {
5757
*/
5858
getReplaceString(text: string, preserveCase?: boolean): string | null {
5959
this._regExp.lastIndex = 0;
60-
let match = this._regExp.exec(text);
60+
const match = this._regExp.exec(text);
6161
if (match) {
6262
if (this.hasParameters) {
6363
if (match[0] === text) {
6464
return text.replace(this._regExp, this.buildReplaceString(match, preserveCase));
6565
}
66-
let replaceString = text.replace(this._regExp, this.buildReplaceString(match, preserveCase));
66+
const replaceString = text.replace(this._regExp, this.buildReplaceString(match, preserveCase));
6767
return replaceString.substr(match.index, match[0].length - (text.length - replaceString.length));
6868
}
6969
return this.buildReplaceString(match, preserveCase);
@@ -94,7 +94,7 @@ export class ReplacePattern {
9494

9595
let substrFrom = 0, result = '';
9696
for (let i = 0, len = replaceString.length; i < len; i++) {
97-
let chCode = replaceString.charCodeAt(i);
97+
const chCode = replaceString.charCodeAt(i);
9898

9999
if (chCode === CharCode.Backslash) {
100100

@@ -106,7 +106,7 @@ export class ReplacePattern {
106106
break;
107107
}
108108

109-
let nextChCode = replaceString.charCodeAt(i);
109+
const nextChCode = replaceString.charCodeAt(i);
110110
let replaceWithCharacter: string | null = null;
111111

112112
switch (nextChCode) {
@@ -140,7 +140,7 @@ export class ReplacePattern {
140140
break;
141141
}
142142

143-
let nextChCode = replaceString.charCodeAt(i);
143+
const nextChCode = replaceString.charCodeAt(i);
144144
let replaceWithCharacter: string | null = null;
145145

146146
switch (nextChCode) {

src/vs/workbench/services/search/common/searchService.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ export class SearchService extends Disposable implements ISearchService {
179179
}
180180

181181
private async waitForProvider(queryType: QueryType, scheme: string): Promise<ISearchResultProvider> {
182-
let deferredMap: Map<string, DeferredPromise<ISearchResultProvider>> = queryType === QueryType.File ?
182+
const deferredMap: Map<string, DeferredPromise<ISearchResultProvider>> = queryType === QueryType.File ?
183183
this.deferredFileSearchesByScheme :
184184
this.deferredTextSearchesByScheme;
185185

0 commit comments

Comments
 (0)