Skip to content

Commit 0e74e08

Browse files
authored
Fix package reset on Windows (#1614)
* Fix package reset on Windows For versions of sourcekit-lsp prior to 6.1, the .build folder cannot be removed for package reset on Windows. To make this work stop the server and then restart it after the reset is done Issue: #1210 * Remove .only * Always stop on windows
1 parent b8bac09 commit 0e74e08

File tree

3 files changed

+22
-7
lines changed

3 files changed

+22
-7
lines changed

src/commands/resetPackage.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,19 @@ export async function folderResetPackage(folderContext: FolderContext) {
4747
folderContext.toolchain
4848
);
4949

50+
const languageClientManager = () =>
51+
folderContext.workspaceContext.languageClientManager.get(folderContext);
52+
const shouldStop = process.platform === "win32";
53+
if (shouldStop) {
54+
await vscode.window.withProgress(
55+
{
56+
title: "Stopping the SourceKit-LSP server",
57+
location: vscode.ProgressLocation.Window,
58+
},
59+
async () => await languageClientManager().stop(false)
60+
);
61+
}
62+
5063
return await executeTaskWithUI(task, "Reset Package", folderContext).then(
5164
async success => {
5265
if (!success) {
@@ -69,6 +82,9 @@ export async function folderResetPackage(folderContext: FolderContext) {
6982
"Resolving Dependencies",
7083
folderContext
7184
);
85+
if (shouldStop) {
86+
await languageClientManager().restart();
87+
}
7288
return result;
7389
},
7490
reason => {

src/sourcekit-lsp/LanguageClientManager.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -176,9 +176,12 @@ export class LanguageClientManager implements vscode.Disposable {
176176

177177
// The language client stops asnyhronously, so we need to wait for it to stop
178178
// instead of doing it in dispose, which must be synchronous.
179-
async stop() {
179+
async stop(dispose: boolean = true) {
180180
if (this.languageClient && this.languageClient.state === State.Running) {
181-
await this.languageClient.dispose();
181+
await this.languageClient.stop(15000);
182+
if (dispose) {
183+
await this.languageClient.dispose();
184+
}
182185
}
183186
}
184187

test/integration-tests/commands/dependency.test.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ suite("Dependency Commmands Test Suite", function () {
5353
});
5454

5555
// Skipping: https://github.com/swiftlang/vscode-swift/issues/1316
56-
suite.skip("Swift: Use Local Dependency", function () {
56+
suite("Swift: Use Local Dependency", function () {
5757
let treeProvider: ProjectPanelProvider;
5858

5959
setup(async () => {
@@ -106,10 +106,6 @@ suite("Dependency Commmands Test Suite", function () {
106106
}
107107

108108
test("Swift: Reset Package Dependencies", async function () {
109-
// spm reset after using local dependency is broken on windows
110-
if (process.platform === "win32") {
111-
this.skip();
112-
}
113109
await useLocalDependencyTest();
114110

115111
// spm reset

0 commit comments

Comments
 (0)