Skip to content

Commit 9b72ee5

Browse files
authored
Improve user feedback if SourceKit-LSP is disabled (#1308)
* Improve user feedback if SourceKit-LSP is disabled Add some notifications to let users know that several things won't work as expected if SourceKit-LSP is disabled. Issue: #892 * Add option to enable sourcekit-lsp in test warning Change the messaging to strongly suggest that no testing features will be available and add an option to allow the user to turn on sourcekit-lsp from the warning prompt in Test Explorer. Issue: #892
1 parent 75c5edc commit 9b72ee5

File tree

3 files changed

+31
-3
lines changed

3 files changed

+31
-3
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -576,7 +576,7 @@
576576
"swift.sourcekit-lsp.disable": {
577577
"type": "boolean",
578578
"default": false,
579-
"markdownDescription": "Disable SourceKit-LSP",
579+
"markdownDescription": "Disable SourceKit-LSP. This will turn off features like code completion, error diagnostics and jump-to-definition. Features like swift-testing test discovery will not work correctly.",
580580
"order": 6
581581
},
582582
"sourcekit-lsp.inlayHints.enabled": {

src/TestExplorer/TestExplorer.ts

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,34 @@ export class TestExplorer {
261261
async discoverTestsInWorkspaceSPM(token: vscode.CancellationToken) {
262262
async function runDiscover(explorer: TestExplorer, firstTry: boolean) {
263263
try {
264+
// we depend on sourcekit-lsp to detect swift-testing tests so let the user know
265+
// that things won't work properly if sourcekit-lsp has been disabled for some reason
266+
// and provide an option to enable sourcekit-lsp again
267+
const ok = "OK";
268+
const enable = "Enable SourceKit-LSP";
269+
if (firstTry && configuration.lsp.disable === true) {
270+
vscode.window
271+
.showInformationMessage(
272+
`swift-testing tests will not be detected since SourceKit-LSP
273+
has been disabled for this workspace.`,
274+
enable,
275+
ok
276+
)
277+
.then(selected => {
278+
if (selected === enable) {
279+
explorer.folderContext.workspaceContext.outputChannel.log(
280+
`Enabling SourceKit-LSP after swift-testing message`
281+
);
282+
vscode.workspace
283+
.getConfiguration("swift")
284+
.update("sourcekit-lsp.disable", false);
285+
} else if (selected === ok) {
286+
explorer.folderContext.workspaceContext.outputChannel.log(
287+
`User acknowledged that SourceKit-LSP is disabled`
288+
);
289+
}
290+
});
291+
}
264292
const toolchain = explorer.folderContext.workspaceContext.toolchain;
265293
// get build options before build is run so we can be sure they aren't changed
266294
// mid-build

src/sourcekit-lsp/LanguageClientManager.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -225,8 +225,8 @@ export class LanguageClientManager implements vscode.Disposable {
225225
// Language client is already stopped
226226
return;
227227
}
228-
message =
229-
"You have disabled the Swift language server, but it is still running. Would you like to stop it now?";
228+
message = `You have disabled the Swift language server, but it is still running. Would you like to stop it now?
229+
This will turn off features such as code completion, error diagnostics, jump-to-definition, and test discovery.`;
230230
restartLSPButton = "Stop Language Server";
231231
} else {
232232
if (this.state !== State.Stopped) {

0 commit comments

Comments
 (0)