mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-21 00:59:03 +01:00
auto-fixed prefer-const violation
This commit is contained in:
@@ -15,9 +15,9 @@ suite('vscode API - commands', () => {
|
||||
|
||||
test('getCommands', function (done) {
|
||||
|
||||
let p1 = commands.getCommands().then(commands => {
|
||||
const p1 = commands.getCommands().then(commands => {
|
||||
let hasOneWithUnderscore = false;
|
||||
for (let command of commands) {
|
||||
for (const command of commands) {
|
||||
if (command[0] === '_') {
|
||||
hasOneWithUnderscore = true;
|
||||
break;
|
||||
@@ -26,9 +26,9 @@ suite('vscode API - commands', () => {
|
||||
assert.ok(hasOneWithUnderscore);
|
||||
}, done);
|
||||
|
||||
let p2 = commands.getCommands(true).then(commands => {
|
||||
const p2 = commands.getCommands(true).then(commands => {
|
||||
let hasOneWithUnderscore = false;
|
||||
for (let command of commands) {
|
||||
for (const command of commands) {
|
||||
if (command[0] === '_') {
|
||||
hasOneWithUnderscore = true;
|
||||
break;
|
||||
@@ -45,7 +45,7 @@ suite('vscode API - commands', () => {
|
||||
test('command with args', async function () {
|
||||
|
||||
let args: IArguments;
|
||||
let registration = commands.registerCommand('t1', function () {
|
||||
const registration = commands.registerCommand('t1', function () {
|
||||
args = arguments;
|
||||
});
|
||||
|
||||
@@ -59,7 +59,7 @@ suite('vscode API - commands', () => {
|
||||
test('editorCommand with extra args', function () {
|
||||
|
||||
let args: IArguments;
|
||||
let registration = commands.registerTextEditorCommand('t1', function () {
|
||||
const registration = commands.registerTextEditorCommand('t1', function () {
|
||||
args = arguments;
|
||||
});
|
||||
|
||||
@@ -79,36 +79,36 @@ suite('vscode API - commands', () => {
|
||||
|
||||
test('api-command: vscode.diff', function () {
|
||||
|
||||
let registration = workspace.registerTextDocumentContentProvider('sc', {
|
||||
const registration = workspace.registerTextDocumentContentProvider('sc', {
|
||||
provideTextDocumentContent(uri) {
|
||||
return `content of URI <b>${uri.toString()}</b>#${Math.random()}`;
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
let a = commands.executeCommand('vscode.diff', Uri.parse('sc:a'), Uri.parse('sc:b'), 'DIFF').then(value => {
|
||||
const a = commands.executeCommand('vscode.diff', Uri.parse('sc:a'), Uri.parse('sc:b'), 'DIFF').then(value => {
|
||||
assert.ok(value === undefined);
|
||||
registration.dispose();
|
||||
});
|
||||
|
||||
let b = commands.executeCommand('vscode.diff', Uri.parse('sc:a'), Uri.parse('sc:b')).then(value => {
|
||||
const b = commands.executeCommand('vscode.diff', Uri.parse('sc:a'), Uri.parse('sc:b')).then(value => {
|
||||
assert.ok(value === undefined);
|
||||
registration.dispose();
|
||||
});
|
||||
|
||||
let c = commands.executeCommand('vscode.diff', Uri.parse('sc:a'), Uri.parse('sc:b'), 'Title', { selection: new Range(new Position(1, 1), new Position(1, 2)) }).then(value => {
|
||||
const c = commands.executeCommand('vscode.diff', Uri.parse('sc:a'), Uri.parse('sc:b'), 'Title', { selection: new Range(new Position(1, 1), new Position(1, 2)) }).then(value => {
|
||||
assert.ok(value === undefined);
|
||||
registration.dispose();
|
||||
});
|
||||
|
||||
let d = commands.executeCommand('vscode.diff').then(() => assert.ok(false), () => assert.ok(true));
|
||||
let e = commands.executeCommand('vscode.diff', 1, 2, 3).then(() => assert.ok(false), () => assert.ok(true));
|
||||
const d = commands.executeCommand('vscode.diff').then(() => assert.ok(false), () => assert.ok(true));
|
||||
const e = commands.executeCommand('vscode.diff', 1, 2, 3).then(() => assert.ok(false), () => assert.ok(true));
|
||||
|
||||
return Promise.all([a, b, c, d, e]);
|
||||
});
|
||||
|
||||
test('api-command: vscode.open', async function () {
|
||||
let uri = Uri.parse(workspace.workspaceFolders![0].uri.toString() + '/far.js');
|
||||
const uri = Uri.parse(workspace.workspaceFolders![0].uri.toString() + '/far.js');
|
||||
|
||||
await commands.executeCommand('vscode.open', uri);
|
||||
assert.strictEqual(window.activeTextEditor?.viewColumn, ViewColumn.One);
|
||||
@@ -151,7 +151,7 @@ suite('vscode API - commands', () => {
|
||||
});
|
||||
|
||||
test('api-command: vscode.open with untitled supports associated resource (#138925)', async function () {
|
||||
let uri = Uri.parse(workspace.workspaceFolders![0].uri.toString() + '/untitled-file.txt').with({ scheme: 'untitled' });
|
||||
const uri = Uri.parse(workspace.workspaceFolders![0].uri.toString() + '/untitled-file.txt').with({ scheme: 'untitled' });
|
||||
await commands.executeCommand('vscode.open', uri).then(() => assert.ok(true), () => assert.ok(false));
|
||||
|
||||
// untitled with associated resource are dirty from the beginning
|
||||
|
||||
@@ -33,7 +33,7 @@ suite('vscode API - languages', () => {
|
||||
let clock = 0;
|
||||
const disposables: vscode.Disposable[] = [];
|
||||
|
||||
let close = new Promise<void>(resolve => {
|
||||
const close = new Promise<void>(resolve => {
|
||||
disposables.push(vscode.workspace.onDidCloseTextDocument(e => {
|
||||
if (e === doc) {
|
||||
assert.strictEqual(doc.languageId, langIdNow);
|
||||
@@ -43,7 +43,7 @@ suite('vscode API - languages', () => {
|
||||
}
|
||||
}));
|
||||
});
|
||||
let open = new Promise<void>(resolve => {
|
||||
const open = new Promise<void>(resolve => {
|
||||
disposables.push(vscode.workspace.onDidOpenTextDocument(e => {
|
||||
if (e === doc) { // same instance!
|
||||
assert.strictEqual(doc.languageId, 'json');
|
||||
@@ -53,7 +53,7 @@ suite('vscode API - languages', () => {
|
||||
}
|
||||
}));
|
||||
});
|
||||
let change = vscode.languages.setTextDocumentLanguage(doc, 'json');
|
||||
const change = vscode.languages.setTextDocumentLanguage(doc, 'json');
|
||||
await Promise.all([change, close, open]);
|
||||
assert.strictEqual(clock, 2);
|
||||
assert.strictEqual(doc.languageId, 'json');
|
||||
@@ -74,19 +74,19 @@ suite('vscode API - languages', () => {
|
||||
});
|
||||
|
||||
test('diagnostics, read & event', function () {
|
||||
let uri = vscode.Uri.file('/foo/bar.txt');
|
||||
let col1 = vscode.languages.createDiagnosticCollection('foo1');
|
||||
const uri = vscode.Uri.file('/foo/bar.txt');
|
||||
const col1 = vscode.languages.createDiagnosticCollection('foo1');
|
||||
col1.set(uri, [new vscode.Diagnostic(new vscode.Range(0, 0, 0, 12), 'error1')]);
|
||||
|
||||
let col2 = vscode.languages.createDiagnosticCollection('foo2');
|
||||
const col2 = vscode.languages.createDiagnosticCollection('foo2');
|
||||
col2.set(uri, [new vscode.Diagnostic(new vscode.Range(0, 0, 0, 12), 'error1')]);
|
||||
|
||||
let diag = vscode.languages.getDiagnostics(uri);
|
||||
const diag = vscode.languages.getDiagnostics(uri);
|
||||
assert.strictEqual(diag.length, 2);
|
||||
|
||||
let tuples = vscode.languages.getDiagnostics();
|
||||
const tuples = vscode.languages.getDiagnostics();
|
||||
let found = false;
|
||||
for (let [thisUri,] of tuples) {
|
||||
for (const [thisUri,] of tuples) {
|
||||
if (thisUri.toString() === uri.toString()) {
|
||||
found = true;
|
||||
break;
|
||||
@@ -114,7 +114,7 @@ suite('vscode API - languages', () => {
|
||||
|
||||
const links = await vscode.commands.executeCommand<vscode.DocumentLink[]>('vscode.executeLinkProvider', doc.uri);
|
||||
assert.strictEqual(links && links.length, 2, links.map(l => !l.target).join(', '));
|
||||
let [link1, link2] = links!.sort((l1, l2) => l1.range.start.compareTo(l2.range.start));
|
||||
const [link1, link2] = links!.sort((l1, l2) => l1.range.start.compareTo(l2.range.start));
|
||||
|
||||
assert.strictEqual(link1.target && link1.target.toString(), target.toString());
|
||||
assertEqualRange(link1.range, range);
|
||||
@@ -132,17 +132,17 @@ suite('vscode API - languages', () => {
|
||||
}
|
||||
}
|
||||
|
||||
let diag1 = new vscode.Diagnostic(new vscode.Range(0, 0, 0, 5), 'montag');
|
||||
let diag2 = new D2();
|
||||
const diag1 = new vscode.Diagnostic(new vscode.Range(0, 0, 0, 5), 'montag');
|
||||
const diag2 = new D2();
|
||||
|
||||
let ran = false;
|
||||
let uri = vscode.Uri.parse('ttt:path.far');
|
||||
const uri = vscode.Uri.parse('ttt:path.far');
|
||||
|
||||
let r1 = vscode.languages.registerCodeActionsProvider({ pattern: '*.far', scheme: 'ttt' }, {
|
||||
const r1 = vscode.languages.registerCodeActionsProvider({ pattern: '*.far', scheme: 'ttt' }, {
|
||||
provideCodeActions(_document, _range, ctx): vscode.Command[] {
|
||||
|
||||
assert.strictEqual(ctx.diagnostics.length, 2);
|
||||
let [first, second] = ctx.diagnostics;
|
||||
const [first, second] = ctx.diagnostics;
|
||||
assert.ok(first === diag1);
|
||||
assert.ok(second === diag2);
|
||||
assert.ok(diag2 instanceof D2);
|
||||
@@ -151,16 +151,16 @@ suite('vscode API - languages', () => {
|
||||
}
|
||||
});
|
||||
|
||||
let r2 = vscode.workspace.registerTextDocumentContentProvider('ttt', {
|
||||
const r2 = vscode.workspace.registerTextDocumentContentProvider('ttt', {
|
||||
provideTextDocumentContent() {
|
||||
return 'this is some text';
|
||||
}
|
||||
});
|
||||
|
||||
let r3 = vscode.languages.createDiagnosticCollection();
|
||||
const r3 = vscode.languages.createDiagnosticCollection();
|
||||
r3.set(uri, [diag1]);
|
||||
|
||||
let r4 = vscode.languages.createDiagnosticCollection();
|
||||
const r4 = vscode.languages.createDiagnosticCollection();
|
||||
r4.set(uri, [diag2]);
|
||||
|
||||
await vscode.workspace.openTextDocument(uri);
|
||||
@@ -171,13 +171,13 @@ suite('vscode API - languages', () => {
|
||||
|
||||
test('completions with document filters', async function () {
|
||||
let ran = false;
|
||||
let uri = vscode.Uri.file(join(vscode.workspace.rootPath || '', './bower.json'));
|
||||
const uri = vscode.Uri.file(join(vscode.workspace.rootPath || '', './bower.json'));
|
||||
|
||||
let jsonDocumentFilter = [{ language: 'json', pattern: '**/package.json' }, { language: 'json', pattern: '**/bower.json' }, { language: 'json', pattern: '**/.bower.json' }];
|
||||
const jsonDocumentFilter = [{ language: 'json', pattern: '**/package.json' }, { language: 'json', pattern: '**/bower.json' }, { language: 'json', pattern: '**/.bower.json' }];
|
||||
|
||||
let r1 = vscode.languages.registerCompletionItemProvider(jsonDocumentFilter, {
|
||||
const r1 = vscode.languages.registerCompletionItemProvider(jsonDocumentFilter, {
|
||||
provideCompletionItems: (_document: vscode.TextDocument, _position: vscode.Position, _token: vscode.CancellationToken): vscode.CompletionItem[] => {
|
||||
let proposal = new vscode.CompletionItem('foo');
|
||||
const proposal = new vscode.CompletionItem('foo');
|
||||
proposal.kind = vscode.CompletionItemKind.Property;
|
||||
ran = true;
|
||||
return [proposal];
|
||||
|
||||
@@ -124,7 +124,7 @@ suite.skip('Notebook Document', function () {
|
||||
|
||||
const p = utils.asPromise(vscode.workspace.onDidOpenNotebookDocument).then(notebook => {
|
||||
for (let i = 0; i < notebook.cellCount; i++) {
|
||||
let cell = notebook.cellAt(i);
|
||||
const cell = notebook.cellAt(i);
|
||||
|
||||
const doc = vscode.workspace.textDocuments.find(doc => doc.uri.toString() === cell.document.uri.toString());
|
||||
assert.ok(doc);
|
||||
|
||||
@@ -51,7 +51,7 @@ import * as utils from '../utils';
|
||||
utils.disposeAll(disposables);
|
||||
disposables.length = 0;
|
||||
|
||||
for (let doc of vscode.workspace.notebookDocuments) {
|
||||
for (const doc of vscode.workspace.notebookDocuments) {
|
||||
assert.strictEqual(doc.isDirty, false, doc.uri.toString());
|
||||
}
|
||||
});
|
||||
|
||||
@@ -30,7 +30,7 @@ import { assertNoRpc, poll } from '../utils';
|
||||
});
|
||||
|
||||
suite('Terminal', () => {
|
||||
let disposables: Disposable[] = [];
|
||||
const disposables: Disposable[] = [];
|
||||
|
||||
teardown(async () => {
|
||||
assertNoRpc();
|
||||
@@ -132,7 +132,7 @@ import { assertNoRpc, poll } from '../utils';
|
||||
}));
|
||||
});
|
||||
equal(result, terminal);
|
||||
let pid = await result.processId;
|
||||
const pid = await result.processId;
|
||||
equal(true, pid && pid > 0);
|
||||
await new Promise<void>(r => {
|
||||
disposables.push(window.onDidCloseTerminal(t => {
|
||||
|
||||
@@ -40,13 +40,13 @@ suite('vscode API - window', () => {
|
||||
|
||||
test('editor, assign and check view columns', async () => {
|
||||
const doc = await workspace.openTextDocument(join(workspace.rootPath || '', './far.js'));
|
||||
let p1 = window.showTextDocument(doc, ViewColumn.One).then(editor => {
|
||||
const p1 = window.showTextDocument(doc, ViewColumn.One).then(editor => {
|
||||
assert.strictEqual(editor.viewColumn, ViewColumn.One);
|
||||
});
|
||||
let p2 = window.showTextDocument(doc, ViewColumn.Two).then(editor_1 => {
|
||||
const p2 = window.showTextDocument(doc, ViewColumn.Two).then(editor_1 => {
|
||||
assert.strictEqual(editor_1.viewColumn, ViewColumn.Two);
|
||||
});
|
||||
let p3 = window.showTextDocument(doc, ViewColumn.Three).then(editor_2 => {
|
||||
const p3 = window.showTextDocument(doc, ViewColumn.Three).then(editor_2 => {
|
||||
assert.strictEqual(editor_2.viewColumn, ViewColumn.Three);
|
||||
});
|
||||
return Promise.all([p1, p2, p3]);
|
||||
@@ -54,7 +54,7 @@ suite('vscode API - window', () => {
|
||||
|
||||
test('editor, onDidChangeVisibleTextEditors', async () => {
|
||||
let eventCounter = 0;
|
||||
let reg = window.onDidChangeVisibleTextEditors(_editor => {
|
||||
const reg = window.onDidChangeVisibleTextEditors(_editor => {
|
||||
eventCounter += 1;
|
||||
});
|
||||
|
||||
@@ -75,7 +75,7 @@ suite('vscode API - window', () => {
|
||||
|
||||
let actualEvent: TextEditorViewColumnChangeEvent;
|
||||
|
||||
let registration1 = workspace.registerTextDocumentContentProvider('bikes', {
|
||||
const registration1 = workspace.registerTextDocumentContentProvider('bikes', {
|
||||
provideTextDocumentContent() {
|
||||
return 'mountainbiking,roadcycling';
|
||||
}
|
||||
@@ -86,10 +86,10 @@ suite('vscode API - window', () => {
|
||||
workspace.openTextDocument(Uri.parse('bikes://testing/two')).then(doc => window.showTextDocument(doc, ViewColumn.Two))
|
||||
]).then(async editors => {
|
||||
|
||||
let [one, two] = editors;
|
||||
const [one, two] = editors;
|
||||
|
||||
await new Promise<void>(resolve => {
|
||||
let registration2 = window.onDidChangeTextEditorViewColumn(event => {
|
||||
const registration2 = window.onDidChangeTextEditorViewColumn(event => {
|
||||
actualEvent = event;
|
||||
registration2.dispose();
|
||||
resolve();
|
||||
@@ -107,9 +107,9 @@ suite('vscode API - window', () => {
|
||||
|
||||
test('editor, onDidChangeTextEditorViewColumn (move editor group)', () => {
|
||||
|
||||
let actualEvents: TextEditorViewColumnChangeEvent[] = [];
|
||||
const actualEvents: TextEditorViewColumnChangeEvent[] = [];
|
||||
|
||||
let registration1 = workspace.registerTextDocumentContentProvider('bikes', {
|
||||
const registration1 = workspace.registerTextDocumentContentProvider('bikes', {
|
||||
provideTextDocumentContent() {
|
||||
return 'mountainbiking,roadcycling';
|
||||
}
|
||||
@@ -120,12 +120,12 @@ suite('vscode API - window', () => {
|
||||
workspace.openTextDocument(Uri.parse('bikes://testing/two')).then(doc => window.showTextDocument(doc, ViewColumn.Two))
|
||||
]).then(editors => {
|
||||
|
||||
let [, two] = editors;
|
||||
const [, two] = editors;
|
||||
two.show();
|
||||
|
||||
return new Promise<void>(resolve => {
|
||||
|
||||
let registration2 = window.onDidChangeTextEditorViewColumn(event => {
|
||||
const registration2 = window.onDidChangeTextEditorViewColumn(event => {
|
||||
actualEvents.push(event);
|
||||
|
||||
if (actualEvents.length === 2) {
|
||||
@@ -182,10 +182,10 @@ suite('vscode API - window', () => {
|
||||
workspace.openTextDocument(randomFile2)
|
||||
]);
|
||||
for (let c = 0; c < 4; c++) {
|
||||
let editorA = await window.showTextDocument(docA, ViewColumn.One);
|
||||
const editorA = await window.showTextDocument(docA, ViewColumn.One);
|
||||
assertActiveEditor(editorA);
|
||||
|
||||
let editorB = await window.showTextDocument(docB, ViewColumn.Two);
|
||||
const editorB = await window.showTextDocument(docB, ViewColumn.Two);
|
||||
assertActiveEditor(editorB);
|
||||
}
|
||||
});
|
||||
@@ -311,7 +311,7 @@ suite('vscode API - window', () => {
|
||||
const file30Path = join(workspace.rootPath || '', './30linefile.ts');
|
||||
|
||||
let finished = false;
|
||||
let failOncePlease = (err: Error) => {
|
||||
const failOncePlease = (err: Error) => {
|
||||
if (finished) {
|
||||
return;
|
||||
}
|
||||
@@ -319,7 +319,7 @@ suite('vscode API - window', () => {
|
||||
done(err);
|
||||
};
|
||||
|
||||
let passOncePlease = () => {
|
||||
const passOncePlease = () => {
|
||||
if (finished) {
|
||||
return;
|
||||
}
|
||||
@@ -327,10 +327,10 @@ suite('vscode API - window', () => {
|
||||
done(null);
|
||||
};
|
||||
|
||||
let subscription = window.onDidChangeTextEditorSelection((e) => {
|
||||
let lineCount = e.textEditor.document.lineCount;
|
||||
let pos1 = e.textEditor.selections[0].active.line;
|
||||
let pos2 = e.selections[0].active.line;
|
||||
const subscription = window.onDidChangeTextEditorSelection((e) => {
|
||||
const lineCount = e.textEditor.document.lineCount;
|
||||
const pos1 = e.textEditor.selections[0].active.line;
|
||||
const pos2 = e.selections[0].active.line;
|
||||
|
||||
if (pos1 !== pos2) {
|
||||
failOncePlease(new Error('received invalid selection changed event!'));
|
||||
@@ -714,7 +714,7 @@ suite('vscode API - window', () => {
|
||||
|
||||
test('#7013 - input without options', function () {
|
||||
const source = new CancellationTokenSource();
|
||||
let p = window.showInputBox(undefined, source.token);
|
||||
const p = window.showInputBox(undefined, source.token);
|
||||
assert.ok(typeof p === 'object');
|
||||
source.dispose();
|
||||
});
|
||||
@@ -990,7 +990,7 @@ suite('vscode API - window', () => {
|
||||
|
||||
return new Promise<void>((resolve, _reject) => {
|
||||
|
||||
let subscription = window.onDidChangeTextEditorSelection(e => {
|
||||
const subscription = window.onDidChangeTextEditorSelection(e => {
|
||||
assert.ok(e.textEditor === editor);
|
||||
assert.strictEqual(e.kind, TextEditorSelectionChangeKind.Command);
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ import { assertNoRpc } from '../utils';
|
||||
});
|
||||
|
||||
suite('Tasks', () => {
|
||||
let disposables: Disposable[] = [];
|
||||
const disposables: Disposable[] = [];
|
||||
|
||||
teardown(() => {
|
||||
assertNoRpc();
|
||||
|
||||
@@ -132,7 +132,7 @@ suite('vscode API - workspace', () => {
|
||||
assert.ok(doc.isDirty);
|
||||
|
||||
let closed: vscode.TextDocument;
|
||||
let d0 = vscode.workspace.onDidCloseTextDocument(e => closed = e);
|
||||
const d0 = vscode.workspace.onDidCloseTextDocument(e => closed = e);
|
||||
|
||||
return vscode.window.showTextDocument(doc).then(() => {
|
||||
return doc.save().then((didSave: boolean) => {
|
||||
@@ -153,7 +153,7 @@ suite('vscode API - workspace', () => {
|
||||
|
||||
test('openTextDocument, uri scheme/auth/path', function () {
|
||||
|
||||
let registration = vscode.workspace.registerTextDocumentContentProvider('sc', {
|
||||
const registration = vscode.workspace.registerTextDocumentContentProvider('sc', {
|
||||
provideTextDocumentContent() {
|
||||
return 'SC';
|
||||
}
|
||||
@@ -182,28 +182,28 @@ suite('vscode API - workspace', () => {
|
||||
const fs = new TestFS('this-fs', false);
|
||||
const reg = vscode.workspace.registerFileSystemProvider(fs.scheme, fs, { isCaseSensitive: fs.isCaseSensitive });
|
||||
|
||||
let uriOne = vscode.Uri.parse('this-fs:/one');
|
||||
let uriTwo = vscode.Uri.parse('this-fs:/two');
|
||||
let uriONE = vscode.Uri.parse('this-fs:/ONE'); // same resource, different uri
|
||||
let uriTWO = vscode.Uri.parse('this-fs:/TWO');
|
||||
const uriOne = vscode.Uri.parse('this-fs:/one');
|
||||
const uriTwo = vscode.Uri.parse('this-fs:/two');
|
||||
const uriONE = vscode.Uri.parse('this-fs:/ONE'); // same resource, different uri
|
||||
const uriTWO = vscode.Uri.parse('this-fs:/TWO');
|
||||
|
||||
fs.writeFile(uriOne, Buffer.from('one'), { create: true, overwrite: true });
|
||||
fs.writeFile(uriTwo, Buffer.from('two'), { create: true, overwrite: true });
|
||||
|
||||
// lower case (actual case) comes first
|
||||
let docOne = await vscode.workspace.openTextDocument(uriOne);
|
||||
const docOne = await vscode.workspace.openTextDocument(uriOne);
|
||||
assert.strictEqual(docOne.uri.toString(), uriOne.toString());
|
||||
|
||||
let docONE = await vscode.workspace.openTextDocument(uriONE);
|
||||
const docONE = await vscode.workspace.openTextDocument(uriONE);
|
||||
assert.strictEqual(docONE === docOne, true);
|
||||
assert.strictEqual(docONE.uri.toString(), uriOne.toString());
|
||||
assert.strictEqual(docONE.uri.toString() !== uriONE.toString(), true); // yep
|
||||
|
||||
// upper case (NOT the actual case) comes first
|
||||
let docTWO = await vscode.workspace.openTextDocument(uriTWO);
|
||||
const docTWO = await vscode.workspace.openTextDocument(uriTWO);
|
||||
assert.strictEqual(docTWO.uri.toString(), uriTWO.toString());
|
||||
|
||||
let docTwo = await vscode.workspace.openTextDocument(uriTwo);
|
||||
const docTwo = await vscode.workspace.openTextDocument(uriTwo);
|
||||
assert.strictEqual(docTWO === docTwo, true);
|
||||
assert.strictEqual(docTwo.uri.toString(), uriTWO.toString());
|
||||
assert.strictEqual(docTwo.uri.toString() !== uriTwo.toString(), true); // yep
|
||||
@@ -264,7 +264,7 @@ suite('vscode API - workspace', () => {
|
||||
|
||||
test('eol, change via onWillSave', async function () {
|
||||
let called = false;
|
||||
let sub = vscode.workspace.onWillSaveTextDocument(e => {
|
||||
const sub = vscode.workspace.onWillSaveTextDocument(e => {
|
||||
called = true;
|
||||
e.waitUntil(Promise.resolve([vscode.TextEdit.setEndOfLine(vscode.EndOfLine.LF)]));
|
||||
});
|
||||
@@ -292,11 +292,11 @@ suite('vscode API - workspace', () => {
|
||||
|
||||
test('events: onDidOpenTextDocument, onDidChangeTextDocument, onDidSaveTextDocument', async () => {
|
||||
const file = await createRandomFile();
|
||||
let disposables: vscode.Disposable[] = [];
|
||||
const disposables: vscode.Disposable[] = [];
|
||||
|
||||
await revertAllDirty(); // needed for a clean state for `onDidSaveTextDocument` (#102365)
|
||||
|
||||
let pendingAsserts: Function[] = [];
|
||||
const pendingAsserts: Function[] = [];
|
||||
let onDidOpenTextDocument = false;
|
||||
disposables.push(vscode.workspace.onDidOpenTextDocument(e => {
|
||||
pendingAsserts.push(() => assertEqualPath(e.uri.fsPath, file.fsPath));
|
||||
@@ -333,8 +333,8 @@ suite('vscode API - workspace', () => {
|
||||
|
||||
test('events: onDidSaveTextDocument fires even for non dirty file when saved', async () => {
|
||||
const file = await createRandomFile();
|
||||
let disposables: vscode.Disposable[] = [];
|
||||
let pendingAsserts: Function[] = [];
|
||||
const disposables: vscode.Disposable[] = [];
|
||||
const pendingAsserts: Function[] = [];
|
||||
|
||||
await revertAllDirty(); // needed for a clean state for `onDidSaveTextDocument` (#102365)
|
||||
|
||||
@@ -369,7 +369,7 @@ suite('vscode API - workspace', () => {
|
||||
|
||||
test('registerTextDocumentContentProvider, simple', function () {
|
||||
|
||||
let registration = vscode.workspace.registerTextDocumentContentProvider('foo', {
|
||||
const registration = vscode.workspace.registerTextDocumentContentProvider('foo', {
|
||||
provideTextDocumentContent(uri) {
|
||||
return uri.toString();
|
||||
}
|
||||
@@ -406,7 +406,7 @@ suite('vscode API - workspace', () => {
|
||||
test('registerTextDocumentContentProvider, multiple', function () {
|
||||
|
||||
// duplicate registration
|
||||
let registration1 = vscode.workspace.registerTextDocumentContentProvider('foo', {
|
||||
const registration1 = vscode.workspace.registerTextDocumentContentProvider('foo', {
|
||||
provideTextDocumentContent(uri) {
|
||||
if (uri.authority === 'foo') {
|
||||
return '1';
|
||||
@@ -414,7 +414,7 @@ suite('vscode API - workspace', () => {
|
||||
return undefined;
|
||||
}
|
||||
});
|
||||
let registration2 = vscode.workspace.registerTextDocumentContentProvider('foo', {
|
||||
const registration2 = vscode.workspace.registerTextDocumentContentProvider('foo', {
|
||||
provideTextDocumentContent(uri) {
|
||||
if (uri.authority === 'bar') {
|
||||
return '2';
|
||||
@@ -435,12 +435,12 @@ suite('vscode API - workspace', () => {
|
||||
test('registerTextDocumentContentProvider, evil provider', function () {
|
||||
|
||||
// duplicate registration
|
||||
let registration1 = vscode.workspace.registerTextDocumentContentProvider('foo', {
|
||||
const registration1 = vscode.workspace.registerTextDocumentContentProvider('foo', {
|
||||
provideTextDocumentContent(_uri) {
|
||||
return '1';
|
||||
}
|
||||
});
|
||||
let registration2 = vscode.workspace.registerTextDocumentContentProvider('foo', {
|
||||
const registration2 = vscode.workspace.registerTextDocumentContentProvider('foo', {
|
||||
provideTextDocumentContent(_uri): string {
|
||||
throw new Error('fail');
|
||||
}
|
||||
@@ -455,7 +455,7 @@ suite('vscode API - workspace', () => {
|
||||
|
||||
test('registerTextDocumentContentProvider, invalid text', function () {
|
||||
|
||||
let registration = vscode.workspace.registerTextDocumentContentProvider('foo', {
|
||||
const registration = vscode.workspace.registerTextDocumentContentProvider('foo', {
|
||||
provideTextDocumentContent(_uri) {
|
||||
return <any>123;
|
||||
}
|
||||
@@ -470,7 +470,7 @@ suite('vscode API - workspace', () => {
|
||||
|
||||
test('registerTextDocumentContentProvider, show virtual document', function () {
|
||||
|
||||
let registration = vscode.workspace.registerTextDocumentContentProvider('foo', {
|
||||
const registration = vscode.workspace.registerTextDocumentContentProvider('foo', {
|
||||
provideTextDocumentContent(_uri) {
|
||||
return 'I am virtual';
|
||||
}
|
||||
@@ -489,7 +489,7 @@ suite('vscode API - workspace', () => {
|
||||
test('registerTextDocumentContentProvider, open/open document', function () {
|
||||
|
||||
let callCount = 0;
|
||||
let registration = vscode.workspace.registerTextDocumentContentProvider('foo', {
|
||||
const registration = vscode.workspace.registerTextDocumentContentProvider('foo', {
|
||||
provideTextDocumentContent(_uri) {
|
||||
callCount += 1;
|
||||
return 'I am virtual';
|
||||
@@ -499,7 +499,7 @@ suite('vscode API - workspace', () => {
|
||||
const uri = vscode.Uri.parse('foo://testing/path');
|
||||
|
||||
return Promise.all([vscode.workspace.openTextDocument(uri), vscode.workspace.openTextDocument(uri)]).then(docs => {
|
||||
let [first, second] = docs;
|
||||
const [first, second] = docs;
|
||||
assert.ok(first === second);
|
||||
assert.ok(vscode.workspace.textDocuments.some(doc => doc.uri.toString() === uri.toString()));
|
||||
assert.strictEqual(callCount, 1);
|
||||
@@ -509,7 +509,7 @@ suite('vscode API - workspace', () => {
|
||||
|
||||
test('registerTextDocumentContentProvider, empty doc', function () {
|
||||
|
||||
let registration = vscode.workspace.registerTextDocumentContentProvider('foo', {
|
||||
const registration = vscode.workspace.registerTextDocumentContentProvider('foo', {
|
||||
provideTextDocumentContent(_uri) {
|
||||
return '';
|
||||
}
|
||||
@@ -527,9 +527,9 @@ suite('vscode API - workspace', () => {
|
||||
test('registerTextDocumentContentProvider, change event', async function () {
|
||||
|
||||
let callCount = 0;
|
||||
let emitter = new vscode.EventEmitter<vscode.Uri>();
|
||||
const emitter = new vscode.EventEmitter<vscode.Uri>();
|
||||
|
||||
let registration = vscode.workspace.registerTextDocumentContentProvider('foo', {
|
||||
const registration = vscode.workspace.registerTextDocumentContentProvider('foo', {
|
||||
onDidChange: emitter.event,
|
||||
provideTextDocumentContent(_uri) {
|
||||
return 'call' + (callCount++);
|
||||
@@ -544,7 +544,7 @@ suite('vscode API - workspace', () => {
|
||||
|
||||
return new Promise<void>(resolve => {
|
||||
|
||||
let subscription = vscode.workspace.onDidChangeTextDocument(event => {
|
||||
const subscription = vscode.workspace.onDidChangeTextDocument(event => {
|
||||
assert.ok(event.document === doc);
|
||||
assert.strictEqual(event.document.getText(), 'call1');
|
||||
subscription.dispose();
|
||||
@@ -635,10 +635,10 @@ suite('vscode API - workspace', () => {
|
||||
test('applyEdit', async () => {
|
||||
const doc = await vscode.workspace.openTextDocument(vscode.Uri.parse('untitled:' + join(vscode.workspace.rootPath || '', './new2.txt')));
|
||||
|
||||
let edit = new vscode.WorkspaceEdit();
|
||||
const edit = new vscode.WorkspaceEdit();
|
||||
edit.insert(doc.uri, new vscode.Position(0, 0), new Array(1000).join('Hello World'));
|
||||
|
||||
let success = await vscode.workspace.applyEdit(edit);
|
||||
const success = await vscode.workspace.applyEdit(edit);
|
||||
assert.strictEqual(success, true);
|
||||
assert.strictEqual(doc.isDirty, true);
|
||||
});
|
||||
@@ -650,7 +650,7 @@ suite('vscode API - workspace', () => {
|
||||
edit.deleteFile(resource);
|
||||
edit.insert(resource, new vscode.Position(0, 0), '');
|
||||
|
||||
let success = await vscode.workspace.applyEdit(edit);
|
||||
const success = await vscode.workspace.applyEdit(edit);
|
||||
assert.strictEqual(success, false);
|
||||
}));
|
||||
|
||||
@@ -661,7 +661,7 @@ suite('vscode API - workspace', () => {
|
||||
edit.deleteFile(resource);
|
||||
edit.renameFile(resource, resource);
|
||||
|
||||
let success = await vscode.workspace.applyEdit(edit);
|
||||
const success = await vscode.workspace.applyEdit(edit);
|
||||
assert.strictEqual(success, false);
|
||||
}));
|
||||
|
||||
@@ -672,7 +672,7 @@ suite('vscode API - workspace', () => {
|
||||
edit.renameFile(resource, newResource);
|
||||
edit.insert(resource, new vscode.Position(0, 0), '');
|
||||
|
||||
let success = await vscode.workspace.applyEdit(edit);
|
||||
const success = await vscode.workspace.applyEdit(edit);
|
||||
assert.strictEqual(success, false);
|
||||
}));
|
||||
|
||||
@@ -698,7 +698,7 @@ suite('vscode API - workspace', () => {
|
||||
|
||||
assert.ok(await vscode.workspace.applyEdit(edit));
|
||||
|
||||
let doc = await vscode.workspace.openTextDocument(newUri);
|
||||
const doc = await vscode.workspace.openTextDocument(newUri);
|
||||
assert.strictEqual(doc.getText(), 'AFTERBEFORE');
|
||||
assert.strictEqual(doc.isDirty, true);
|
||||
}
|
||||
@@ -708,25 +708,25 @@ suite('vscode API - workspace', () => {
|
||||
}
|
||||
|
||||
test('WorkspaceEdit: applying edits before and after rename duplicates resource #42633', withLogDisabled(async function () {
|
||||
let docUri = await createRandomFile();
|
||||
let newUri = nameWithUnderscore(docUri);
|
||||
const docUri = await createRandomFile();
|
||||
const newUri = nameWithUnderscore(docUri);
|
||||
|
||||
let we = new vscode.WorkspaceEdit();
|
||||
const we = new vscode.WorkspaceEdit();
|
||||
we.insert(docUri, new vscode.Position(0, 0), 'Hello');
|
||||
we.insert(docUri, new vscode.Position(0, 0), 'Foo');
|
||||
we.renameFile(docUri, newUri);
|
||||
we.insert(newUri, new vscode.Position(0, 0), 'Bar');
|
||||
|
||||
assert.ok(await vscode.workspace.applyEdit(we));
|
||||
let doc = await vscode.workspace.openTextDocument(newUri);
|
||||
const doc = await vscode.workspace.openTextDocument(newUri);
|
||||
assert.strictEqual(doc.getText(), 'BarHelloFoo');
|
||||
}));
|
||||
|
||||
test('WorkspaceEdit: Problem recreating a renamed resource #42634', withLogDisabled(async function () {
|
||||
let docUri = await createRandomFile();
|
||||
let newUri = nameWithUnderscore(docUri);
|
||||
const docUri = await createRandomFile();
|
||||
const newUri = nameWithUnderscore(docUri);
|
||||
|
||||
let we = new vscode.WorkspaceEdit();
|
||||
const we = new vscode.WorkspaceEdit();
|
||||
we.insert(docUri, new vscode.Position(0, 0), 'Hello');
|
||||
we.insert(docUri, new vscode.Position(0, 0), 'Foo');
|
||||
we.renameFile(docUri, newUri);
|
||||
@@ -736,15 +736,15 @@ suite('vscode API - workspace', () => {
|
||||
|
||||
assert.ok(await vscode.workspace.applyEdit(we));
|
||||
|
||||
let newDoc = await vscode.workspace.openTextDocument(newUri);
|
||||
const newDoc = await vscode.workspace.openTextDocument(newUri);
|
||||
assert.strictEqual(newDoc.getText(), 'HelloFoo');
|
||||
let doc = await vscode.workspace.openTextDocument(docUri);
|
||||
const doc = await vscode.workspace.openTextDocument(docUri);
|
||||
assert.strictEqual(doc.getText(), 'Bar');
|
||||
}));
|
||||
|
||||
test('WorkspaceEdit api - after saving a deleted file, it still shows up as deleted. #42667', withLogDisabled(async function () {
|
||||
let docUri = await createRandomFile();
|
||||
let we = new vscode.WorkspaceEdit();
|
||||
const docUri = await createRandomFile();
|
||||
const we = new vscode.WorkspaceEdit();
|
||||
we.deleteFile(docUri);
|
||||
we.insert(docUri, new vscode.Position(0, 0), 'InsertText');
|
||||
|
||||
@@ -759,14 +759,14 @@ suite('vscode API - workspace', () => {
|
||||
|
||||
test('WorkspaceEdit: edit and rename parent folder duplicates resource #42641', async function () {
|
||||
|
||||
let dir = vscode.Uri.parse(`${testFs.scheme}:/before-${rndName()}`);
|
||||
const dir = vscode.Uri.parse(`${testFs.scheme}:/before-${rndName()}`);
|
||||
await testFs.createDirectory(dir);
|
||||
|
||||
let docUri = await createRandomFile('', dir);
|
||||
let docParent = docUri.with({ path: posix.dirname(docUri.path) });
|
||||
let newParent = nameWithUnderscore(docParent);
|
||||
const docUri = await createRandomFile('', dir);
|
||||
const docParent = docUri.with({ path: posix.dirname(docUri.path) });
|
||||
const newParent = nameWithUnderscore(docParent);
|
||||
|
||||
let we = new vscode.WorkspaceEdit();
|
||||
const we = new vscode.WorkspaceEdit();
|
||||
we.insert(docUri, new vscode.Position(0, 0), 'Hello');
|
||||
we.renameFile(docParent, newParent);
|
||||
|
||||
@@ -779,30 +779,30 @@ suite('vscode API - workspace', () => {
|
||||
assert.ok(true);
|
||||
}
|
||||
|
||||
let newUri = newParent.with({ path: posix.join(newParent.path, posix.basename(docUri.path)) });
|
||||
let doc = await vscode.workspace.openTextDocument(newUri);
|
||||
const newUri = newParent.with({ path: posix.join(newParent.path, posix.basename(docUri.path)) });
|
||||
const doc = await vscode.workspace.openTextDocument(newUri);
|
||||
assert.ok(doc);
|
||||
|
||||
assert.strictEqual(doc.getText(), 'Hello');
|
||||
});
|
||||
|
||||
test('WorkspaceEdit: rename resource followed by edit does not work #42638', withLogDisabled(async function () {
|
||||
let docUri = await createRandomFile();
|
||||
let newUri = nameWithUnderscore(docUri);
|
||||
const docUri = await createRandomFile();
|
||||
const newUri = nameWithUnderscore(docUri);
|
||||
|
||||
let we = new vscode.WorkspaceEdit();
|
||||
const we = new vscode.WorkspaceEdit();
|
||||
we.renameFile(docUri, newUri);
|
||||
we.insert(newUri, new vscode.Position(0, 0), 'Hello');
|
||||
|
||||
assert.ok(await vscode.workspace.applyEdit(we));
|
||||
|
||||
let doc = await vscode.workspace.openTextDocument(newUri);
|
||||
const doc = await vscode.workspace.openTextDocument(newUri);
|
||||
assert.strictEqual(doc.getText(), 'Hello');
|
||||
}));
|
||||
|
||||
test('WorkspaceEdit: create & override', withLogDisabled(async function () {
|
||||
|
||||
let docUri = await createRandomFile('before');
|
||||
const docUri = await createRandomFile('before');
|
||||
|
||||
let we = new vscode.WorkspaceEdit();
|
||||
we.createFile(docUri);
|
||||
@@ -816,7 +816,7 @@ suite('vscode API - workspace', () => {
|
||||
}));
|
||||
|
||||
test('WorkspaceEdit: create & ignoreIfExists', withLogDisabled(async function () {
|
||||
let docUri = await createRandomFile('before');
|
||||
const docUri = await createRandomFile('before');
|
||||
|
||||
let we = new vscode.WorkspaceEdit();
|
||||
we.createFile(docUri, { ignoreIfExists: true });
|
||||
@@ -830,8 +830,8 @@ suite('vscode API - workspace', () => {
|
||||
}));
|
||||
|
||||
test('WorkspaceEdit: rename & ignoreIfExists', withLogDisabled(async function () {
|
||||
let aUri = await createRandomFile('aaa');
|
||||
let bUri = await createRandomFile('bbb');
|
||||
const aUri = await createRandomFile('aaa');
|
||||
const bUri = await createRandomFile('bbb');
|
||||
|
||||
let we = new vscode.WorkspaceEdit();
|
||||
we.renameFile(aUri, bUri);
|
||||
@@ -852,7 +852,7 @@ suite('vscode API - workspace', () => {
|
||||
|
||||
test('WorkspaceEdit: delete & ignoreIfNotExists', withLogDisabled(async function () {
|
||||
|
||||
let docUri = await createRandomFile();
|
||||
const docUri = await createRandomFile();
|
||||
let we = new vscode.WorkspaceEdit();
|
||||
we.deleteFile(docUri, { ignoreIfNotExists: false });
|
||||
assert.ok(await vscode.workspace.applyEdit(we));
|
||||
@@ -868,14 +868,14 @@ suite('vscode API - workspace', () => {
|
||||
|
||||
test('WorkspaceEdit: insert & rename multiple', async function () {
|
||||
|
||||
let [f1, f2, f3] = await Promise.all([createRandomFile(), createRandomFile(), createRandomFile()]);
|
||||
const [f1, f2, f3] = await Promise.all([createRandomFile(), createRandomFile(), createRandomFile()]);
|
||||
|
||||
let we = new vscode.WorkspaceEdit();
|
||||
const we = new vscode.WorkspaceEdit();
|
||||
we.insert(f1, new vscode.Position(0, 0), 'f1');
|
||||
we.insert(f2, new vscode.Position(0, 0), 'f2');
|
||||
we.insert(f3, new vscode.Position(0, 0), 'f3');
|
||||
|
||||
let f1_ = nameWithUnderscore(f1);
|
||||
const f1_ = nameWithUnderscore(f1);
|
||||
we.renameFile(f1, f1_);
|
||||
|
||||
assert.ok(await vscode.workspace.applyEdit(we));
|
||||
@@ -911,7 +911,7 @@ suite('vscode API - workspace', () => {
|
||||
}
|
||||
|
||||
for (let i = 0; i < 4; i++) {
|
||||
let we = new vscode.WorkspaceEdit();
|
||||
const we = new vscode.WorkspaceEdit();
|
||||
let oldUri: vscode.Uri;
|
||||
let newUri: vscode.Uri;
|
||||
let expected: string;
|
||||
@@ -946,7 +946,7 @@ suite('vscode API - workspace', () => {
|
||||
test('The api workspace.applyEdit failed for some case of mixing resourceChange and textEdit #80688', async function () {
|
||||
const file1 = await createRandomFile();
|
||||
const file2 = await createRandomFile();
|
||||
let we = new vscode.WorkspaceEdit();
|
||||
const we = new vscode.WorkspaceEdit();
|
||||
we.insert(file1, new vscode.Position(0, 0), 'import1;');
|
||||
|
||||
const file2Name = basename(file2.fsPath);
|
||||
@@ -965,7 +965,7 @@ suite('vscode API - workspace', () => {
|
||||
test('The api workspace.applyEdit failed for some case of mixing resourceChange and textEdit #80688', async function () {
|
||||
const file1 = await createRandomFile();
|
||||
const file2 = await createRandomFile();
|
||||
let we = new vscode.WorkspaceEdit();
|
||||
const we = new vscode.WorkspaceEdit();
|
||||
we.insert(file1, new vscode.Position(0, 0), 'import1;');
|
||||
we.insert(file1, new vscode.Position(0, 0), 'import2;');
|
||||
|
||||
@@ -990,7 +990,7 @@ suite('vscode API - workspace', () => {
|
||||
const file2New = await createRandomFile();
|
||||
|
||||
const event = new Promise<vscode.FileWillRenameEvent>(resolve => {
|
||||
let sub = vscode.workspace.onWillRenameFiles(e => {
|
||||
const sub = vscode.workspace.onWillRenameFiles(e => {
|
||||
sub.dispose();
|
||||
resolve(e);
|
||||
});
|
||||
@@ -1035,7 +1035,7 @@ suite('vscode API - workspace', () => {
|
||||
test('Should send a single FileWillRenameEvent instead of separate events when moving multiple files at once#111867, 2/3', async function () {
|
||||
|
||||
const event = new Promise<vscode.FileWillCreateEvent>(resolve => {
|
||||
let sub = vscode.workspace.onWillCreateFiles(e => {
|
||||
const sub = vscode.workspace.onWillCreateFiles(e => {
|
||||
sub.dispose();
|
||||
resolve(e);
|
||||
});
|
||||
@@ -1062,7 +1062,7 @@ suite('vscode API - workspace', () => {
|
||||
const file2 = await createRandomFile();
|
||||
|
||||
const event = new Promise<vscode.FileWillDeleteEvent>(resolve => {
|
||||
let sub = vscode.workspace.onWillDeleteFiles(e => {
|
||||
const sub = vscode.workspace.onWillDeleteFiles(e => {
|
||||
sub.dispose();
|
||||
resolve(e);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user