From 8df0335ac89b2a4d89f74a7d78c656c9e4842487 Mon Sep 17 00:00:00 2001 From: Youssef Amr El-Shehaby Date: Sun, 10 Nov 2024 08:54:53 +0200 Subject: [PATCH] Fix: Prevent folder opening in tree views --- CHANGELOG.md | 6 ++++++ src/providers/layouts-provider.ts | 12 +++++++----- src/providers/pages-provider.ts | 12 +++++++----- 3 files changed, 20 insertions(+), 10 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 733ce14..8d13b2a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,12 @@ All notable changes to **Project Explorer** will be documented in this file. +## [0.3.1] 2024-11-10 + +### Fixed + +- Prevent folders in the pages and layouts tree views from being opened as files when clicked. This ensures only valid files are opened, improving user experience. + ## [0.3.0] 2024-3-1 ### Added diff --git a/src/providers/layouts-provider.ts b/src/providers/layouts-provider.ts index b91a505..e04875c 100644 --- a/src/providers/layouts-provider.ts +++ b/src/providers/layouts-provider.ts @@ -56,11 +56,13 @@ export default class LayoutsProvider ? vscode.TreeItemCollapsibleState.Collapsed : vscode.TreeItemCollapsibleState.None, - { - command: "vscode.open", - title: "", - arguments: [vscode.Uri.file(filePath)], - } + file.isDirectory() + ? undefined + : { + command: "vscode.open", + title: "", + arguments: [vscode.Uri.file(filePath)], + } ); fileTreeItem.resourceUri = vscode.Uri.file(filePath); if (!file.isDirectory() && !file.name.includes("layout")) { diff --git a/src/providers/pages-provider.ts b/src/providers/pages-provider.ts index d36e571..5d99b4f 100644 --- a/src/providers/pages-provider.ts +++ b/src/providers/pages-provider.ts @@ -56,11 +56,13 @@ export default class PagesProvider ? vscode.TreeItemCollapsibleState.Collapsed : vscode.TreeItemCollapsibleState.None, - { - command: "vscode.open", - title: "", - arguments: [vscode.Uri.file(filePath)], - } + file.isDirectory() + ? undefined + : { + command: "vscode.open", + title: "", + arguments: [vscode.Uri.file(filePath)], + } ); fileTreeItem.resourceUri = vscode.Uri.file(filePath); if (!file.isDirectory() && !file.name.includes("page")) {