|
4 | 4 | import * as fse from "fs-extra";
|
5 | 5 | import * as _ from "lodash";
|
6 | 6 | import * as minimatch from "minimatch";
|
| 7 | +import * as path from "path"; |
7 | 8 | import { commands, Disposable, ExtensionContext, Uri, window, workspace, WorkspaceFolder } from "vscode";
|
8 | 9 | import { instrumentOperation } from "vscode-extension-telemetry-wrapper";
|
9 | 10 | import { Commands } from "../commands";
|
@@ -62,9 +63,19 @@ export class LibraryController implements Disposable {
|
62 | 63 | Settings.updateReferencedLibraries(setting);
|
63 | 64 | }
|
64 | 65 |
|
65 |
| - public async removeLibrary(library: string) { |
| 66 | + public async removeLibrary(removalFsPath: string) { |
66 | 67 | 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 | + } |
68 | 79 | Settings.updateReferencedLibraries(setting);
|
69 | 80 | }
|
70 | 81 |
|
|
0 commit comments