diff --git a/CodeEdit/Features/NavigatorArea/ProjectNavigator/OutlineView/ProjectNavigatorMenuActions.swift b/CodeEdit/Features/NavigatorArea/ProjectNavigator/OutlineView/ProjectNavigatorMenuActions.swift index 9ab9d3ed2..8f469e329 100644 --- a/CodeEdit/Features/NavigatorArea/ProjectNavigator/OutlineView/ProjectNavigatorMenuActions.swift +++ b/CodeEdit/Features/NavigatorArea/ProjectNavigator/OutlineView/ProjectNavigatorMenuActions.swift @@ -6,6 +6,7 @@ // import AppKit +import SwiftUI extension ProjectNavigatorMenu { /// - Returns: the currently selected `CEWorkspaceFile` items in the outline view. @@ -150,6 +151,9 @@ extension ProjectNavigatorMenu { func trash() { selectedItems().forEach { item in workspace?.workspaceFileManager?.trash(file: item) + withAnimation { + sender.editor?.closeTab(file: item) + } } reloadData() } @@ -165,6 +169,13 @@ extension ProjectNavigatorMenu { } else { workspace?.workspaceFileManager?.batchDelete(files: selectedItems) } + + withAnimation { + selectedItems.forEach { item in + sender.editor?.closeTab(file: item) + } + } + reloadData() } diff --git a/CodeEdit/Features/NavigatorArea/ProjectNavigator/OutlineView/ProjectNavigatorOutlineView.swift b/CodeEdit/Features/NavigatorArea/ProjectNavigator/OutlineView/ProjectNavigatorOutlineView.swift index cb9456663..5b97d09b2 100644 --- a/CodeEdit/Features/NavigatorArea/ProjectNavigator/OutlineView/ProjectNavigatorOutlineView.swift +++ b/CodeEdit/Features/NavigatorArea/ProjectNavigator/OutlineView/ProjectNavigatorOutlineView.swift @@ -12,6 +12,7 @@ import Combine struct ProjectNavigatorOutlineView: NSViewControllerRepresentable { @EnvironmentObject var workspace: WorkspaceDocument + @EnvironmentObject var editorManager: EditorManager @StateObject var prefs: Settings = .shared @@ -21,6 +22,7 @@ struct ProjectNavigatorOutlineView: NSViewControllerRepresentable { let controller = ProjectNavigatorViewController() controller.workspace = workspace controller.iconColor = prefs.preferences.general.fileIconStyle + controller.editor = editorManager.activeEditor workspace.workspaceFileManager?.addObserver(context.coordinator) context.coordinator.controller = controller diff --git a/CodeEdit/Features/NavigatorArea/ProjectNavigator/OutlineView/ProjectNavigatorViewController.swift b/CodeEdit/Features/NavigatorArea/ProjectNavigator/OutlineView/ProjectNavigatorViewController.swift index 8851fd1ec..f76f07efc 100644 --- a/CodeEdit/Features/NavigatorArea/ProjectNavigator/OutlineView/ProjectNavigatorViewController.swift +++ b/CodeEdit/Features/NavigatorArea/ProjectNavigator/OutlineView/ProjectNavigatorViewController.swift @@ -36,6 +36,7 @@ final class ProjectNavigatorViewController: NSViewController { var expandedItems: Set = [] weak var workspace: WorkspaceDocument? + weak var editor: Editor? var iconColor: SettingsData.FileIconStyle = .color { willSet {