Skip to content

Commit 479b7f6

Browse files
authored
bugfix: Cannot remove jar if it's already in the include field (#223)
1 parent 40f90b1 commit 479b7f6

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

src/controllers/libraryController.ts

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import * as fse from "fs-extra";
55
import * as _ from "lodash";
66
import * as minimatch from "minimatch";
7+
import * as path from "path";
78
import { commands, Disposable, ExtensionContext, Uri, window, workspace, WorkspaceFolder } from "vscode";
89
import { instrumentOperation } from "vscode-extension-telemetry-wrapper";
910
import { Commands } from "../commands";
@@ -62,9 +63,19 @@ export class LibraryController implements Disposable {
6263
Settings.updateReferencedLibraries(setting);
6364
}
6465

65-
public async removeLibrary(library: string) {
66+
public async removeLibrary(removalFsPath: string) {
6667
const setting = Settings.referencedLibraries();
67-
setting.exclude = this.updatePatternArray(setting.exclude, workspace.asRelativePath(library, false));
68+
const removedPaths = _.remove(setting.include, (include) => {
69+
if (path.isAbsolute(include)) {
70+
return Uri.file(include).fsPath === removalFsPath;
71+
} else {
72+
return include === workspace.asRelativePath(removalFsPath, false);
73+
}
74+
});
75+
if (removedPaths.length === 0) {
76+
// No duplicated item in include array, add it into the exclude field
77+
setting.exclude = this.updatePatternArray(setting.exclude, workspace.asRelativePath(removalFsPath, false));
78+
}
6879
Settings.updateReferencedLibraries(setting);
6980
}
7081

0 commit comments

Comments
 (0)