Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve user feedback if SourceKit-LSP is disabled #1308

Merged
merged 2 commits into from
Jan 21, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -570,7 +570,7 @@
"swift.sourcekit-lsp.disable": {
"type": "boolean",
"default": false,
"markdownDescription": "Disable SourceKit-LSP",
"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.",
"order": 6
},
"sourcekit-lsp.inlayHints.enabled": {
Expand Down
28 changes: 28 additions & 0 deletions src/TestExplorer/TestExplorer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,34 @@ export class TestExplorer {
async discoverTestsInWorkspaceSPM(token: vscode.CancellationToken) {
async function runDiscover(explorer: TestExplorer, firstTry: boolean) {
try {
// we depend on sourcekit-lsp to detect swift-testing tests so let the user know
// that things won't work properly if sourcekit-lsp has been disabled for some reason
// and provide an option to enable sourcekit-lsp again
const ok = "OK";
const enable = "Enable SourceKit-LSP";
if (firstTry && configuration.lsp.disable === true) {
vscode.window
.showInformationMessage(
`swift-testing tests will not be detected since SourceKit-LSP
has been disabled for this workspace.`,
enable,
ok
)
.then(selected => {
if (selected === enable) {
explorer.folderContext.workspaceContext.outputChannel.log(
`Enabling SourceKit-LSP after swift-testing message`
);
vscode.workspace
.getConfiguration("swift")
.update("sourcekit-lsp.disable", false);
} else if (selected === ok) {
explorer.folderContext.workspaceContext.outputChannel.log(
`User acknowledged that SourceKit-LSP is disabled`
);
}
});
}
const toolchain = explorer.folderContext.workspaceContext.toolchain;
// get build options before build is run so we can be sure they aren't changed
// mid-build
Expand Down
4 changes: 2 additions & 2 deletions src/sourcekit-lsp/LanguageClientManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -225,8 +225,8 @@ export class LanguageClientManager implements vscode.Disposable {
// Language client is already stopped
return;
}
message =
"You have disabled the Swift language server, but it is still running. Would you like to stop it now?";
message = `You have disabled the Swift language server, but it is still running. Would you like to stop it now?
This will turn off features such as code completion, error diagnostics, jump-to-definition, and test discovery.`;
restartLSPButton = "Stop Language Server";
} else {
if (this.state !== State.Stopped) {
Expand Down
Loading