Skip to content

Commit

Permalink
Deleting a file in the Workspace UI now closes the tab (#1937)
Browse files Browse the repository at this point in the history
Co-authored-by: Leonardo Larrañaga <leonardolarranaga@icloud.com>
  • Loading branch information
LeonardoLarranaga and Leonardo Larrañaga authored Nov 18, 2024
1 parent adf6fa7 commit 4cd81be
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
//

import AppKit
import SwiftUI

extension ProjectNavigatorMenu {
/// - Returns: the currently selected `CEWorkspaceFile` items in the outline view.
Expand Down Expand Up @@ -150,6 +151,9 @@ extension ProjectNavigatorMenu {
func trash() {
selectedItems().forEach { item in
workspace?.workspaceFileManager?.trash(file: item)
withAnimation {
sender.editor?.closeTab(file: item)
}
}
reloadData()
}
Expand All @@ -165,6 +169,13 @@ extension ProjectNavigatorMenu {
} else {
workspace?.workspaceFileManager?.batchDelete(files: selectedItems)
}

withAnimation {
selectedItems.forEach { item in
sender.editor?.closeTab(file: item)
}
}

reloadData()
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import Combine
struct ProjectNavigatorOutlineView: NSViewControllerRepresentable {

@EnvironmentObject var workspace: WorkspaceDocument
@EnvironmentObject var editorManager: EditorManager

@StateObject var prefs: Settings = .shared

Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ final class ProjectNavigatorViewController: NSViewController {
var expandedItems: Set<CEWorkspaceFile> = []

weak var workspace: WorkspaceDocument?
weak var editor: Editor?

var iconColor: SettingsData.FileIconStyle = .color {
willSet {
Expand Down

0 comments on commit 4cd81be

Please sign in to comment.