Skip to content

Commit dea0c2f

Browse files
committed
Enable multi selection in library list view
Signed-off-by: Seb Julliand <[email protected]>
1 parent 6b2e0f2 commit dea0c2f

File tree

2 files changed

+20
-11
lines changed

2 files changed

+20
-11
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2616,7 +2616,7 @@
26162616
},
26172617
{
26182618
"command": "code-for-ibmi.setCurrentLibrary",
2619-
"when": "view == libraryListView && viewItem == library",
2619+
"when": "view == libraryListView && viewItem == library && !listMultiSelection",
26202620
"group": "01libraryActions@01"
26212621
},
26222622
{

src/ui/views/LibraryListView.ts

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ export function initializeLibraryListView(context: vscode.ExtensionContext) {
1111
`libraryListView`, {
1212
treeDataProvider: libraryListView,
1313
showCollapseAll: false,
14-
canSelectMany: false,
14+
canSelectMany: true,
1515
dragAndDropController: new LibraryListDragAndDrop()
1616
});
1717

@@ -170,22 +170,31 @@ export function initializeLibraryListView(context: vscode.ExtensionContext) {
170170
}
171171
}),
172172

173-
vscode.commands.registerCommand(`code-for-ibmi.removeFromLibraryList`, async (node: LibraryListNode) => {
173+
vscode.commands.registerCommand(`code-for-ibmi.removeFromLibraryList`, async (node: LibraryListNode, nodes?: LibraryListNode[]) => {
174174
if (node) {
175175
//Running from right click
176+
nodes = nodes ? nodes : [node];
176177
const connection = instance.getConnection();
177178
if (connection) {
178179
const config = connection.getConfig();
179-
let libraryList = config.libraryList;
180+
const libraryList = config.libraryList;
180181

181-
let index = libraryList.findIndex(library => connection.upperCaseName(library) === node.library)
182-
if (index >= 0) {
183-
const removedLib = libraryList[index];
184-
libraryList.splice(index, 1);
182+
const removedLibs: string[] = [];
183+
nodes.map(n => n.library).forEach(lib => {
184+
const index = libraryList.findIndex(library => connection.upperCaseName(library) === lib)
185+
if (index >= 0) {
186+
removedLibs.push(libraryList[index]);
187+
libraryList.splice(index, 1);
188+
}
189+
});
185190

186-
config.libraryList = libraryList;
187-
await updateConfig(config);
188-
vscode.window.showInformationMessage(l10n.t(`Library {0} was removed from the library list.`, removedLib));
191+
config.libraryList = libraryList;
192+
await updateConfig(config);
193+
if (removedLibs.length === 1) {
194+
vscode.window.showInformationMessage(l10n.t(`Library {0} was removed from the library list.`, removedLibs.join("")));
195+
}
196+
else {
197+
vscode.window.showInformationMessage(l10n.t(`Libraries {0} were removed from the library list.`, removedLibs.join(", ")));
189198
}
190199
}
191200
}

0 commit comments

Comments
 (0)