Skip to content

Commit

Permalink
feat: capability to open changed file in temp tab (#1472)
Browse files Browse the repository at this point in the history
* feat: capability to open changed file in temp tab

* fix: remove whitespace
  • Loading branch information
EstebanBorai authored Nov 3, 2023
1 parent 25bfeb2 commit 239b1cf
Showing 1 changed file with 11 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@
import SwiftUI

struct SourceControlNavigatorChangedFileView: View {
@EnvironmentObject var workspace: WorkspaceDocument

@ObservedObject var sourceControlManager: SourceControlManager

var changedFile: CEWorkspaceFile

var folder: String? {
Expand Down Expand Up @@ -67,8 +70,9 @@ struct SourceControlNavigatorChangedFileView: View {
Divider()
}
Group {
Button("Open in New Tab") {}
.disabled(true) // TODO: Implementation Needed
Button("Open in New Tab") {
openInTemporaryTab()
}
Button("Open in New Window") {}
.disabled(true) // TODO: Implementation Needed
Button("Open with External Editor") {}
Expand All @@ -87,6 +91,11 @@ struct SourceControlNavigatorChangedFileView: View {
.padding(.horizontal)
}

/// Opens the file in a new temporary tab
func openInTemporaryTab() {
self.workspace.editorManager.activeEditor.openTab(item: self.changedFile, asTemporary: true)
}

func toggleSelectedFileState() {
setSelectedFile(!getSelectedFileState())
}
Expand Down

0 comments on commit 239b1cf

Please sign in to comment.