Skip to content

Commit 2f43db1

Browse files
fix: export to language actions appear for regular playground results VSCODE-334 (#434)
* fix: export to language actions appear for regular playground results VSCODE-334 * test: try without disabling extensions * test: return disable extensions arg * refactor: fix spaces in package.json * refactor: remove metadata * test: try to set setting in tests * test: try other settings format * fix: write settings to global * test: try to disable from connection controller * test: trigger ci again to check * test: remove disabling the dialogue for prompting the user where to store the connection
1 parent f145c89 commit 2f43db1

File tree

5 files changed

+200
-24
lines changed

5 files changed

+200
-24
lines changed

package-lock.json

Lines changed: 151 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/editors/exportToLanguageCodeLensProvider.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,10 @@ export default class ExportToLanguageCodeLensProvider
4545
const buildersCodeLens = this.createCodeLens();
4646
const exportToLanguageCodeLenses: vscode.CodeLens[] = [];
4747

48+
if (['json', 'plaintext'].includes(this._exportToLanguageAddons.language)) {
49+
return [];
50+
}
51+
4852
importStatementsCodeLens.command = {
4953
title: this._exportToLanguageAddons.importStatements
5054
? 'Exclude Import Statements'

src/editors/playgroundController.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -397,6 +397,11 @@ export default class PlaygroundController {
397397
this._playgroundResultTextDocument,
398398
language
399399
);
400+
401+
this._exportToLanguageCodeLensProvider.refresh({
402+
...this._exportToLanguageCodeLensProvider._exportToLanguageAddons,
403+
language,
404+
});
400405
}
401406
}
402407

src/test/suite/editors/exportToLanguageCodeLensProvider.test.ts

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,4 +120,30 @@ suite('Export To Language Code Lens Provider Test Suite', function () {
120120

121121
expect(codeLenses.length).to.be.equal(2);
122122
});
123+
124+
test('does not render code lenses for json text', () => {
125+
testExportToLanguageCodeLensProvider.refresh({
126+
...defaults,
127+
builders: true,
128+
mode: ExportToLanguageMode.OTHER,
129+
language: 'json',
130+
});
131+
132+
const codeLenses = testExportToLanguageCodeLensProvider.provideCodeLenses();
133+
134+
expect(codeLenses.length).to.be.equal(0);
135+
});
136+
137+
test('does not render code lenses for plain text text', () => {
138+
testExportToLanguageCodeLensProvider.refresh({
139+
...defaults,
140+
builders: true,
141+
mode: ExportToLanguageMode.OTHER,
142+
language: 'plaintext',
143+
});
144+
145+
const codeLenses = testExportToLanguageCodeLensProvider.provideCodeLenses();
146+
147+
expect(codeLenses.length).to.be.equal(0);
148+
});
123149
});

src/test/suite/index.ts

Lines changed: 14 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import Mocha from 'mocha';
22
import glob from 'glob';
3-
import * as vscode from 'vscode';
43
import path = require('path');
54
import MDBExtensionController from '../../mdbExtensionController';
65
import { ext } from '../../extensionConstants';
@@ -51,28 +50,22 @@ export async function run(): Promise<void> {
5150
// headless linux.
5251
ext.keytarModule = new KeytarStub();
5352

54-
// Disable the dialogue for prompting the user where to store the connection.
55-
void vscode.workspace
56-
.getConfiguration('mdb.connectionSaving')
57-
.update('hideOptionToChooseWhereToSaveNewConnections', true)
58-
.then(() => {
59-
// Add files to the test suite.
60-
files.forEach((f) => mocha.addFile(path.resolve(testsRoot, f)));
61-
try {
62-
// Run the mocha test.
63-
mocha.run((failures) => {
64-
if (failures > 0) {
65-
e(new Error(`${failures} tests failed.`));
66-
} else {
67-
c();
68-
}
69-
});
70-
} catch (mochaRunErr) {
71-
console.error('Error running mocha tests:');
72-
console.error(mochaRunErr);
73-
e(mochaRunErr);
53+
// Add files to the test suite.
54+
files.forEach((f) => mocha.addFile(path.resolve(testsRoot, f)));
55+
try {
56+
// Run the mocha test.
57+
mocha.run((failures) => {
58+
if (failures > 0) {
59+
e(new Error(`${failures} tests failed.`));
60+
} else {
61+
c();
7462
}
7563
});
64+
} catch (mochaRunErr) {
65+
console.error('Error running mocha tests:');
66+
console.error(mochaRunErr);
67+
e(mochaRunErr);
68+
}
7669
}
7770
);
7871
});

0 commit comments

Comments
 (0)