Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deleting a file in the Workspace UI now closes the tab #1937

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading