adds nice git interface

This commit is contained in:
2026-10-30 13:21:45 +01:00
parent b9c03a7637
commit caec81e762
107 changed files with 6466 additions and 3992 deletions
@@ -42,29 +42,12 @@ extension WorkspaceModel {
// MARK: Row menus
/// ⌘→ in Source Control or Explorer: the selected row's menu, beside the column at the row's height.
/// ⌘→ in the Explorer: the selected row's menu, beside the column at the row's height.
func openRowMenu() {
switch layout.activePanel {
case .sourceControl:
guard let row = selectedGitRow() else { return }
showContextMenu(.gitRow(path: row.change.path, staged: row.change.staged),
anchor: rowMenuAnchor(.sourceControl, frame: rowFrames[.git(row.change.id)],
estimate: row.index, rowHeight: Metrics.sourceControlRow))
case .explorer:
guard let row = selectedTreeRow() else { return }
showContextMenu(ExplorerStore.target(for: row.row),
anchor: rowMenuAnchor(.explorer, frame: rowFrames[.tree(row.row.path)],
estimate: row.index, rowHeight: Metrics.explorerRow))
default:
break
}
}
func selectedGitRow() -> (change: Change, index: Int)? {
guard let sourceControl else { return nil }
let rows = sourceControl.rows
guard let index = rows.firstIndex(where: { $0.id == sourceControl.selectedRowID }) else { return nil }
return (rows[index], index)
guard layout.activePanel == .explorer, let row = selectedTreeRow() else { return }
showContextMenu(ExplorerStore.target(for: row.row),
anchor: rowMenuAnchor(.explorer, frame: rowFrames[.tree(row.row.path)],
estimate: row.index, rowHeight: Metrics.explorerRow))
}
func selectedTreeRow() -> (row: TreeRow, index: Int)? {
@@ -90,7 +73,13 @@ extension WorkspaceModel {
let sourceControl = sourceControl, explorer = explorer, editor = editor
switch action {
case let .passOnReference(reference, code):
closeGitView()
overlay.present(.passOn(PassOnRequest(reference: reference, code: code, anchor: anchor)))
case let .openFile(path):
closeGitView()
open(path)
case let .commit(andPush):
track { await sourceControl?.commit(andPush: andPush) }
case let .passOnFileName(name):
overlay.present(.passOn(PassOnRequest(reference: name, anchor: anchor)))
case let .bouwen(name):
@@ -118,18 +107,16 @@ extension WorkspaceModel {
case let .rename(path, isDirectory):
overlay.present(.namePrompt(NamePromptRequest(purpose: .rename(path: path, isDirectory: isDirectory),
initialName: PathUtils.basename(path), anchor: anchor)))
case let .openDiff(path):
open(path, OpenOptions(showDiff: true))
case let .showDiff(path, line):
if editor?.activePath == path { editor?.openDiff(atLine: line) }
case let .copyTerminalSelection(kind):
if let text = terminal.selection(kind) { app.system.copy(text) }
case let .pasteIntoTerminal(kind):
if let text = app.system.pasteboardText() { terminal.paste(text, into: kind) }
case let .discard(path):
case let .gitDiscard(paths):
track {
await sourceControl?.discard(path)
await editor?.reloadFromDisk(path)
await sourceControl?.discard(paths)
for path in paths where editor?.isLoaded(path) == true { await editor?.reloadFromDisk(path) }
}
case let .delete(path, isDirectory):
track {
@@ -138,10 +125,7 @@ extension WorkspaceModel {
await sourceControl?.refresh()
}
default:
track {
if await sourceControl?.perform(action) == true { return }
await explorer?.perform(action)
}
track { _ = await explorer?.perform(action) }
}
}