From 89bb19d12844e39234b79eb131a408445dcb0654 Mon Sep 17 00:00:00 2001 From: Youssef Amr El-Shehaby Date: Tue, 12 Dec 2023 15:27:33 +0200 Subject: [PATCH] feat: show all active text editors --- src/providers/active-editors-provider.ts | 29 ++++++++++++++---------- 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/src/providers/active-editors-provider.ts b/src/providers/active-editors-provider.ts index 936ab14..f25699a 100644 --- a/src/providers/active-editors-provider.ts +++ b/src/providers/active-editors-provider.ts @@ -33,18 +33,23 @@ export default class ActiveEditorsProvider getChildren( element?: ActiveEditorsTreeItem | undefined ): vscode.ProviderResult { - try { - const activeEditors = vscode.window.visibleTextEditors; - this.refresh(); - return activeEditors.map((editor) => { - return new ActiveEditorsTreeItem( - editor.document!.fileName, - vscode.TreeItemCollapsibleState.None - ); - }); - } catch (err) { - return []; - } + const openDocuments = vscode.workspace.textDocuments; + const activeEditors: ActiveEditorsTreeItem[] = []; + this.refresh(); + openDocuments.forEach((editor) => { + if (editor.fileName.endsWith(".git")) { + return null; + } + const activeEditor = new ActiveEditorsTreeItem( + "\\" + + editor.fileName.substring( + editor.fileName.indexOf("app\\") + "app\\".length + ), + vscode.TreeItemCollapsibleState.None + ); + activeEditors.push(activeEditor); + }); + return activeEditors; } closeEditor(element: ActiveEditorsTreeItem) { vscode.window.visibleTextEditors.map((editor) => {