From 239b1cf37d40b9c6fea0039f318fde10b7b4fea7 Mon Sep 17 00:00:00 2001 From: Esteban Borai Date: Fri, 3 Nov 2023 11:40:59 -0300 Subject: [PATCH] feat: capability to open changed file in temp tab (#1472) * feat: capability to open changed file in temp tab * fix: remove whitespace --- .../SourceControlNavigatorChangedFileView.swift | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/CodeEdit/Features/NavigatorArea/SourceControlNavigator/Views/Changes/SourceControlNavigatorChangedFileView.swift b/CodeEdit/Features/NavigatorArea/SourceControlNavigator/Views/Changes/SourceControlNavigatorChangedFileView.swift index d9c4ecdc6..ecaf3db0c 100644 --- a/CodeEdit/Features/NavigatorArea/SourceControlNavigator/Views/Changes/SourceControlNavigatorChangedFileView.swift +++ b/CodeEdit/Features/NavigatorArea/SourceControlNavigator/Views/Changes/SourceControlNavigatorChangedFileView.swift @@ -8,7 +8,10 @@ import SwiftUI struct SourceControlNavigatorChangedFileView: View { + @EnvironmentObject var workspace: WorkspaceDocument + @ObservedObject var sourceControlManager: SourceControlManager + var changedFile: CEWorkspaceFile var folder: String? { @@ -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") {} @@ -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()) }