From a0b3ef9975b97b32cc474bf820e79761b757c96c Mon Sep 17 00:00:00 2001 From: Jonathan van Rij Date: Wed, 7 Oct 2026 13:02:52 +0200 Subject: [PATCH] Improve loads of fancy things in relation to the mouse pointer --- Sources/HelderCore/Files/ContextActions.swift | 32 +++++++--- .../Components/PointerBoundTextView.swift | 16 ++++- .../HelderUI/Components/PointerPolicy.swift | 9 ++- .../Editor/CodeEditorController.swift | 26 +++++---- Sources/HelderUI/Editor/CodeTextView.swift | 9 --- Sources/HelderUI/Editor/EditorPane.swift | 8 +-- .../HelderUI/Editor/EditorPresentation.swift | 4 +- .../Overlays/ContextMenuOverlay.swift | 5 +- Sources/HelderUI/State/EditorStore.swift | 10 ++-- .../State/WorkspaceModel+ContextActions.swift | 4 ++ TODO-editor-pointer-and-show-diff.md | 36 ++++++++++++ .../Files/ContextActionsTests.swift | 58 +++++++++++++++++++ .../Editor/CodeEditorShowDiffTests.swift | 57 ++++++++++++++++++ .../Editor/EditorLayoutTests.swift | 16 ++++- .../Editor/EditorScrollOriginTests.swift | 2 +- .../Editor/EditorStoreTests.swift | 19 +++++- .../Explorer/ExplorerStoreTests.swift | 2 +- .../Overlays/ContextMenuTintTests.swift | 6 ++ .../State/WorkspaceModelTests.swift | 16 +++++ docs/behaviour.md | 6 +- docs/guide/file-view-diff.md | 6 +- docs/guide/file-view.md | 4 +- docs/guide/keyboard-shortcuts.md | 2 +- docs/guide/pass-on-to-agent.md | 26 ++++----- docs/guide/right-click-menu.md | 44 +++++++++----- 25 files changed, 334 insertions(+), 89 deletions(-) create mode 100644 TODO-editor-pointer-and-show-diff.md create mode 100644 Tests/HelderUITests/Editor/CodeEditorShowDiffTests.swift diff --git a/Sources/HelderCore/Files/ContextActions.swift b/Sources/HelderCore/Files/ContextActions.swift index f3164fc..8e179bc 100644 --- a/Sources/HelderCore/Files/ContextActions.swift +++ b/Sources/HelderCore/Files/ContextActions.swift @@ -3,7 +3,8 @@ import Foundation /// What was right-clicked. public enum ContextTarget: Sendable, Equatable { /// A line or selection in the editor; `code` is the selected text, if any. - case editor(reference: AgentReference, code: String?) + /// `showDiffLine` is the clicked line when it is marked and the file offers its Diff. + case editor(reference: AgentReference, code: String?, showDiffLine: Int? = nil) case file(path: String) case directory(path: String) /// A git row; the row carries its own half, since one file can have two rows. @@ -14,7 +15,7 @@ public enum ContextTarget: Sendable, Equatable { public var path: String { switch self { - case let .editor(reference, _): reference.path + case let .editor(reference, _, _): reference.path case let .file(path), let .directory(path), let .gitRow(path, _): path case .projectRoot, .terminal: "" } @@ -32,12 +33,16 @@ public enum ContextAction: Sendable, Equatable { case stage(String) case unstage(String) case openDiff(String) + /// Opens the Diff of the open file at this line. + case showDiff(String, line: Int) case discard(String) case rename(String, isDirectory: Bool) case revealInFinder(String) case delete(String, isDirectory: Bool) case copyTerminalSelection(TerminalKind) case pasteIntoTerminal(TerminalKind) + /// Inserts `/bouwen ` into the agent composer for an ontwikkeling folder. + case bouwen(String) /// Destructive items read in amber-deep. public var isDestructive: Bool { @@ -55,27 +60,28 @@ public enum ContextMenuEntry: Sendable, Equatable { } public enum ContextActions { - /// The header line of the menu: the reference, or `project/` for the root. + /// The header line of the menu: the path, or `project/` for the root; the editor, folders and terminals have none. public static func header(for target: ContextTarget, projectName: String) -> String { switch target { - case let .editor(reference, _): reference.description - case let .directory(path): path + "/" case let .file(path), let .gitRow(path, _): path case .projectRoot: projectName + "/" - case .terminal: "" + case .editor, .directory, .terminal: "" } } /// Menu entries: every "Pass on …" item has its "Copy …" twin directly below. public static func entries(for target: ContextTarget) -> [ContextMenuEntry] { switch target { - case let .editor(reference, code): + case let .editor(reference, code, showDiffLine): let ref = reference.description let hasCode = !(code ?? "").isEmpty + let showDiff: [ContextMenuEntry] = showDiffLine.map { + [.separator, .action(.showDiff(reference.path, line: $0), label: "Show diff")] + } ?? [] return [ .action(.passOnReference(ref, code: hasCode ? code : nil), label: hasCode ? "Pass on selection" : "Pass on reference"), .action(.copyReference(ref), label: "Copy reference"), - ] + ] + showDiff case .projectRoot: return [ .action(.newFile(inDirectory: ""), label: "New file"), @@ -90,7 +96,8 @@ public enum ContextActions { ] case let .directory(path): let ref = path + "/" - return [ + let bouwen: [ContextMenuEntry] = ontwikkelingName(path).map { [.action(.bouwen($0), label: "Bouwen"), .separator] } ?? [] + return bouwen + [ .action(.passOnReference(ref, code: nil), label: "Pass on reference"), .action(.copyReference(ref), label: "Copy reference"), .separator, @@ -114,6 +121,13 @@ public enum ContextActions { } } + /// The folder name of a direct child of `ontwikkelingen/`, except the `ontwikkeld` archive. + private static func ontwikkelingName(_ path: String) -> String? { + let parts = path.split(separator: "/", omittingEmptySubsequences: false) + guard parts.count == 2, parts[0] == "ontwikkelingen", !parts[1].isEmpty, parts[1] != "ontwikkeld" else { return nil } + return String(parts[1]) + } + private static func fileHead(_ path: String) -> [ContextMenuEntry] { let name = PathUtils.basename(path) return [ diff --git a/Sources/HelderUI/Components/PointerBoundTextView.swift b/Sources/HelderUI/Components/PointerBoundTextView.swift index 8cb8e0f..448a423 100644 --- a/Sources/HelderUI/Components/PointerBoundTextView.swift +++ b/Sources/HelderUI/Components/PointerBoundTextView.swift @@ -36,10 +36,20 @@ class PointerBoundTextView: NSTextView, PointerTextTarget { addPointerCursorRect(visibleRectWithoutScrollers) } + /// NSTextView's own `mouseMoved` sets the I-beam, so it runs only where the policy gives the I-beam; + /// under an overlay it would flip the pointer to the I-beam and back on every move. override func mouseMoved(with event: NSEvent) { guard let point = mouseLocation, isTopmost(atWindowPoint: point) else { return } - super.mouseMoved(with: event) - applyPointer(pointerShape(isOverText: true), atWindowPoint: point) + let shape = pointerShape(isOverText: true) + if shape == .iBeam { super.mouseMoved(with: event) } + applyPointer(shape, atWindowPoint: point) + } + + /// NSTextView's `mouseEntered` sets the I-beam itself, so it runs only where the policy allows the I-beam. + override func mouseEntered(with event: NSEvent) { + if allowsIBeamRect { super.mouseEntered(with: event) } + guard let window, !PointerPolicy.isSelecting else { return } + PointerPolicy.updateCursor(in: window) } /// An update meant for another view is handed to the view under the mouse. @@ -73,6 +83,8 @@ class PointerBoundTextView: NSTextView, PointerTextTarget { super.viewDidMoveToSuperview() NotificationCenter.default.removeObserver(self, name: NSView.frameDidChangeNotification, object: nil) guard let clip = superview as? NSClipView else { return } + // NSTextView gives its clip view an I-beam document cursor, whose rect would bypass the policy under an overlay. + clip.documentCursor = nil clip.postsFrameChangedNotifications = true NotificationCenter.default.addObserver(self, selector: #selector(clipFrameChanged), name: NSView.frameDidChangeNotification, object: clip) diff --git a/Sources/HelderUI/Components/PointerPolicy.swift b/Sources/HelderUI/Components/PointerPolicy.swift index 15e4ab2..b5cf795 100644 --- a/Sources/HelderUI/Components/PointerPolicy.swift +++ b/Sources/HelderUI/Components/PointerPolicy.swift @@ -93,10 +93,13 @@ extension NSView { hitView(atWindowPoint: point)?.isDescendant(of: self) ?? false } - /// The visible rect minus the enclosing scroll view's scrollers, which keep the arrow. + /// The visible rect minus the enclosing scroll view's scrollers and line-number ruler, which keep the arrow. + /// The clip view runs under a visible ruler, so the visible rect alone would give the gutter the I-beam. var visibleRectWithoutScrollers: NSRect { - let scrollers = [enclosingScrollView?.verticalScroller, enclosingScrollView?.horizontalScroller] - return scrollers.compactMap { $0 }.filter { !$0.isHidden && $0.superview != nil } + let scroll = enclosingScrollView + let ruler: NSView? = scroll?.rulersVisible == true ? scroll?.verticalRulerView : nil + let strips: [NSView?] = [scroll?.verticalScroller, scroll?.horizontalScroller, ruler] + return strips.compactMap { $0 }.filter { !$0.isHidden && $0.superview != nil } .reduce(visibleRect) { $0.removing(convert($1.bounds, from: $1)) } } } diff --git a/Sources/HelderUI/Editor/CodeEditorController.swift b/Sources/HelderUI/Editor/CodeEditorController.swift index 287d739..2e717a4 100644 --- a/Sources/HelderUI/Editor/CodeEditorController.swift +++ b/Sources/HelderUI/Editor/CodeEditorController.swift @@ -16,7 +16,7 @@ struct CodeEditorConfiguration { /// Cheap identity of the marks; `makeMarks` runs only when it moves. var marksKey: String var makeMarks: () -> [Int: CodeLineMark] - var opensDiffOnClick: Bool + var offersShowDiff: Bool var knownSymbols: Set var symbolsVersion: Int var flash: LineFlash? @@ -33,9 +33,8 @@ struct CodeEditorActions { var edited: (String) -> Void = { _ in } var cursorMoved: (_ line: Int, _ column: Int) -> Void = { _, _ in } var selectionChanged: (_ lines: ClosedRange?, _ code: String?) -> Void = { _, _ in } - var markedLineClicked: (Int) -> Void = { _ in } - /// Reference, selected code, and the anchor in top-left window coordinates. - var contextMenu: (AgentReference, String?, CGPoint) -> Void = { _, _, _ in } + /// Reference, selected code, the line that offers Show diff, and the anchor in top-left window coordinates. + var contextMenu: (AgentReference, String?, Int?, CGPoint) -> Void = { _, _, _, _ in } var symbolClicked: (String) -> Void = { _ in } /// ⌘→ with a selection; returns false when there was nothing to pass. var passOnSelection: (CGPoint) -> Bool = { _ in false } @@ -436,12 +435,17 @@ final class CodeEditorController: NSObject, NSTextViewDelegate, NSLayoutManagerD return doc.lineIndex.line(containing: characterIndex(atWindowPoint: point)) } - /// A plain click on a marked line in Actual opens the Diff there. - func plainClick(atWindowPoint point: NSPoint) { - guard configuration?.opensDiffOnClick == true, - let line = line(atWindowPoint: point), marks[line] != nil else { return } - let action = actions.markedLineClicked - DispatchQueue.main.async { action(line) } + /// The marked line under the point when the file offers Show diff. The whole row counts, + /// so a blank line and the space after the last glyph hit too. + func showDiffLine(atWindowPoint point: NSPoint) -> Int? { + guard configuration?.offersShowDiff == true else { return nil } + let local = textView.convert(point, from: nil) + var hit: Int? + forEachRow(in: NSRect(x: 0, y: local.y, width: max(1, textView.bounds.width), height: 1)) { row in + if hit == nil, row.rect.minY <= local.y, local.y < row.rect.maxY { hit = row.line } + } + guard let hit, marks[hit] != nil else { return nil } + return hit } /// ⌘-click: follows a class name the project declares. @@ -472,7 +476,7 @@ final class CodeEditorController: NSObject, NSTextViewDelegate, NSLayoutManagerD let lines = selection.length > 0 ? EditorReference.lines(of: selection, in: doc.lineIndex) : nil let code = selection.length > 0 ? (doc.storage.string as NSString).substring(with: clamped(selection, in: doc)) : nil let reference = EditorReference.make(path: configuration.path, selectedLines: lines, clickedLine: clicked) - actions.contextMenu(reference, code, topLeft(event.locationInWindow)) + actions.contextMenu(reference, code, showDiffLine(atWindowPoint: event.locationInWindow), topLeft(event.locationInWindow)) } func passOnSelection() -> Bool { diff --git a/Sources/HelderUI/Editor/CodeTextView.swift b/Sources/HelderUI/Editor/CodeTextView.swift index 470b5f0..d9b4148 100644 --- a/Sources/HelderUI/Editor/CodeTextView.swift +++ b/Sources/HelderUI/Editor/CodeTextView.swift @@ -4,8 +4,6 @@ import AppKit final class CodeTextView: PointerBoundTextView { weak var controller: CodeEditorController? - /// Pointer travel that still counts as a click and not as a text selection. - private static let dragSlop: CGFloat = 4 private var pointerTracking: NSTrackingArea? override func drawBackground(in rect: NSRect) { @@ -20,14 +18,7 @@ final class CodeTextView: PointerBoundTextView { override func mouseDown(with event: NSEvent) { if event.modifierFlags.contains(.command), controller?.followSymbol(at: event) == true { return } - let hadSelection = selectedRange().length > 0 - let down = event.locationInWindow super.mouseDown(with: event) - guard event.clickCount == 1, !hadSelection, selectedRange().length == 0, - event.modifierFlags.isDisjoint(with: [.shift, .option, .command, .control]), - let up = window?.mouseLocationOutsideOfEventStream, - abs(up.x - down.x) + abs(up.y - down.y) <= Self.dragSlop else { return } - controller?.plainClick(atWindowPoint: down) } override func menu(for event: NSEvent) -> NSMenu? { diff --git a/Sources/HelderUI/Editor/EditorPane.swift b/Sources/HelderUI/Editor/EditorPane.swift index 54d7c96..f90887f 100644 --- a/Sources/HelderUI/Editor/EditorPane.swift +++ b/Sources/HelderUI/Editor/EditorPane.swift @@ -56,7 +56,7 @@ struct EditorPane: View { tabSize: editor.editorConfig.tabSize, marksKey: marked.map { "actual:" + Self.stamp($0) } ?? "none", makeMarks: { marked.map { ChangeMarks.actual(DiffViews.actual($0)) } ?? [:] }, - opensDiffOnClick: presentation.opensDiffOnClick, knownSymbols: editor.knownSymbols, + offersShowDiff: presentation.offersShowDiff, knownSymbols: editor.knownSymbols, symbolsVersion: editor.knownSymbolsVersion, flash: editor.flash, focusRequest: editor.textFocusRequest, selectAllRequest: editor.selectAllRequest, fontScale: fontScale, isShown: isShown) @@ -73,9 +73,9 @@ struct EditorPane: View { edited: { editor.edit($0) }, cursorMoved: { editor.updateCursor(line: $0, column: $1) }, selectionChanged: { editor.updateSelection(lines: $0, code: $1) }, - markedLineClicked: { editor.openDiff(atLine: $0) }, - contextMenu: { reference, code, anchor in - editor.presentOverlay?(.contextMenu(editor.contextMenuRequest(reference: reference, code: code, anchor: anchor))) + contextMenu: { reference, code, showDiffLine, anchor in + let request = editor.contextMenuRequest(reference: reference, code: code, showDiffLine: showDiffLine, anchor: anchor) + editor.presentOverlay?(.contextMenu(request)) }, symbolClicked: { editor.lookupSymbol($0) }, passOnSelection: { anchor in diff --git a/Sources/HelderUI/Editor/EditorPresentation.swift b/Sources/HelderUI/Editor/EditorPresentation.swift index b9cf1b9..6ff25e1 100644 --- a/Sources/HelderUI/Editor/EditorPresentation.swift +++ b/Sources/HelderUI/Editor/EditorPresentation.swift @@ -114,6 +114,6 @@ public struct EditorPresentation: Equatable, Sendable { /// Actual and Code edit the live buffer; Preview is a read-only view. public var isEditable: Bool { kind == .text && placeholder == nil && (paneMode == .code || paneMode == .actual) } - /// A click on a marked line opens the Diff, except on a new file where every line is marked. - public var opensDiffOnClick: Bool { paneMode == .actual && hasDiff && status != .added } + /// A marked line offers Show diff, except on a new file where every line is marked. + public var offersShowDiff: Bool { paneMode == .actual && hasDiff && status != .added } } diff --git a/Sources/HelderUI/Overlays/ContextMenuOverlay.swift b/Sources/HelderUI/Overlays/ContextMenuOverlay.swift index 6651c92..c65ebeb 100644 --- a/Sources/HelderUI/Overlays/ContextMenuOverlay.swift +++ b/Sources/HelderUI/Overlays/ContextMenuOverlay.swift @@ -111,7 +111,7 @@ struct ContextMenuOverlay: View { case .copyReference, .copyTerminalSelection, .pasteIntoTerminal: .plain case .newFile, .newFolder, .stage: .add case .copyFileName, .unstage, .revealInFinder: .modify - case .passOnReference, .passOnFileName, .openDiff, .rename: .rename + case .passOnReference, .passOnFileName, .bouwen, .openDiff, .showDiff, .rename: .rename case .discard, .delete: .danger } } @@ -119,13 +119,14 @@ struct ContextMenuOverlay: View { nonisolated static func symbol(for action: ContextAction) -> String { switch action { case .passOnReference, .passOnFileName: ContextMenuRow.spark + case .bouwen: "hammer" case .copyReference, .copyFileName, .copyTerminalSelection: "doc.on.doc" case .pasteIntoTerminal: "doc.on.clipboard" case .newFile: "doc.badge.plus" case .newFolder: "folder.badge.plus" case .stage: "plus" case .unstage: "minus" - case .openDiff: "arrow.left.arrow.right" + case .openDiff, .showDiff: "arrow.left.arrow.right" case .discard: "arrow.uturn.backward" case .rename: "pencil" case .revealInFinder: "folder" diff --git a/Sources/HelderUI/State/EditorStore.swift b/Sources/HelderUI/State/EditorStore.swift index 37ed7a9..f62371b 100644 --- a/Sources/HelderUI/State/EditorStore.swift +++ b/Sources/HelderUI/State/EditorStore.swift @@ -270,7 +270,7 @@ public final class EditorStore { track { await $0.load(path, discardEdits: false) } } - /// A click on a marked line in Actual: the Diff opens on HEAD vs disk, centred on that line. + /// Show diff on a marked line in Actual: the Diff opens on HEAD vs disk, centred on that line. public func openDiff(atLine line: Int) { guard let path = activePath, diff(for: path) != nil else { return } let current = mode(for: path) @@ -308,9 +308,11 @@ public final class EditorStore { return PassOnRequest(reference: selection.reference.description, code: code, anchor: anchor) } - /// The right-click menu for a line or selection in the code: exactly Pass on and Copy reference. - public func contextMenuRequest(reference: AgentReference, code: String?, anchor: CGPoint) -> ContextMenuRequest { - let target = ContextTarget.editor(reference: reference, code: code) + /// The right-click menu for a line or selection in the code: Pass on and Copy reference, plus Show diff + /// when `showDiffLine` names a marked line. + public func contextMenuRequest(reference: AgentReference, code: String?, showDiffLine: Int? = nil, + anchor: CGPoint) -> ContextMenuRequest { + let target = ContextTarget.editor(reference: reference, code: code, showDiffLine: showDiffLine) return ContextMenuRequest(target: target, header: ContextActions.header(for: target, projectName: PathUtils.basename(root)), entries: ContextActions.entries(for: target), anchor: anchor) } diff --git a/Sources/HelderUI/State/WorkspaceModel+ContextActions.swift b/Sources/HelderUI/State/WorkspaceModel+ContextActions.swift index 5af5f01..c57fd86 100644 --- a/Sources/HelderUI/State/WorkspaceModel+ContextActions.swift +++ b/Sources/HelderUI/State/WorkspaceModel+ContextActions.swift @@ -93,6 +93,8 @@ extension WorkspaceModel { overlay.present(.passOn(PassOnRequest(reference: reference, code: code, anchor: anchor))) case let .passOnFileName(name): overlay.present(.passOn(PassOnRequest(reference: name, anchor: anchor))) + case let .bouwen(name): + passToAgent("/bouwen \(name)", toast: "/bouwen \(name)") case let .newFile(directory): overlay.present(.namePrompt(NamePromptRequest(purpose: .newFile(inDirectory: directory), anchor: anchor))) case let .newFolder(directory): @@ -102,6 +104,8 @@ extension WorkspaceModel { 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): diff --git a/TODO-editor-pointer-and-show-diff.md b/TODO-editor-pointer-and-show-diff.md new file mode 100644 index 0000000..78d4124 --- /dev/null +++ b/TODO-editor-pointer-and-show-diff.md @@ -0,0 +1,36 @@ +# To do: editor pointer flicker and "Show diff" + +Status on 2026-10-07: items 2 and 3 built and tested (not yet checked in the running app); item 1 open. + +## 1. Pointer flicker on a changed file + +A file with a git change shows its changed lines with a tinted background. + +- [x] Hover over the editor without a menu: steady pointer. Fixed: the line-number gutter is cut out of the I-beam rect (`visibleRectWithoutScrollers` in `Components/PointerPolicy.swift`). +- [ ] With the right-click menu open on a changed file, moving the mouse still flickers a bit between arrow and I-beam. Expected: a steady arrow over the menu and over every column behind it. + - Suspects: `CodeTextView`'s mouseMoved tracking area, NSTextView's own `mouseEntered` → `_mouseInside:` (already re-routed in `PointerBoundTextView`), the I-beam cursor rects of the `CodeScrollView` clip view, row-background redraws that reset cursor rects, and SwiftUI updates of the editor while the file changes on disk. + - Find the setter at runtime with a temporary `NSCursor.set` trace, fix it through `PointerPolicy`, then remove the trace. + +## 2. Show diff from the right-click menu, not from a click + +- [x] A left click on a changed line places the caret like any line, and never opens the Diff. Remove `CodeEditorController.plainClick`, `actions.markedLineClicked`, the call in `CodeTextView.mouseDown` and the wiring in `EditorPane.swift` (`editor.openDiff(atLine:)`). +- [x] A right-click on a changed line shows the editor menu with a separator and **Show diff** below Pass on reference / Copy reference. It opens the Diff of that file at that line (`editor.openDiff(atLine:)`). + - Every marked line counts, including blank added lines and the area after the last glyph of a line. + - Same conditions as the old click: Actual mode, the file has a diff, not a newly added file (`EditorPresentation.opensDiffOnClick`, rename it). + - An unchanged line: menu unchanged. The menu in `DiffOverlayView` gets no Show diff. + - Plumbing: `ContextActions.entries(for: .editor…)`, `EditorStore.contextMenuRequest`, `WorkspaceModel+ContextActions.execute`, tint and symbol in `ContextMenuOverlay` (same as `.openDiff`). + +## 3. No header on the editor menu + +- [x] The editor right-click menu loses its header line (for example `sample.php:12`), also in the Diff view. `ContextActions.header` returns "" for `.editor`. File, git-row and project-root menus keep theirs. + +## Done in this session (uncommitted) + +- Bouwen item on `ontwikkelingen/` folders. +- Arrow instead of the I-beam over the context menu where it covers the editor (`PointerBoundTextView.mouseEntered`). +- No header on folder menus. + +## Verify + +- Tests and docs for each item, as in the earlier changes (`docs/guide/right-click-menu.md`, `docs/behaviour.md`). +- Check in the running app; drive the mouse only when Jonathan is away from the machine. diff --git a/Tests/HelderCoreTests/Files/ContextActionsTests.swift b/Tests/HelderCoreTests/Files/ContextActionsTests.swift index 22b25b3..3c20491 100644 --- a/Tests/HelderCoreTests/Files/ContextActionsTests.swift +++ b/Tests/HelderCoreTests/Files/ContextActionsTests.swift @@ -23,5 +23,63 @@ import Testing @Test func theMenuHasNoHeader() { #expect(ContextActions.header(for: .terminal(.agent, hasSelection: false), projectName: "app").isEmpty) + #expect(ContextActions.header(for: .directory(path: "src"), projectName: "app").isEmpty) + } +} + +@Suite struct EditorContextMenuTests { + private let reference = AgentReference(path: "src/a.php", startLine: 12) + + @Test func theEditorMenuHasNoHeader() { + #expect(ContextActions.header(for: .editor(reference: reference, code: nil), projectName: "app").isEmpty) + #expect(ContextActions.header(for: .editor(reference: reference, code: "x", showDiffLine: 12), projectName: "app").isEmpty) + } + + @Test func fileGitRowAndRootMenusKeepTheirHeader() { + #expect(ContextActions.header(for: .file(path: "src/a.php"), projectName: "app") == "src/a.php") + #expect(ContextActions.header(for: .gitRow(path: "src/a.php", staged: false), projectName: "app") == "src/a.php") + #expect(ContextActions.header(for: .projectRoot, projectName: "app") == "app/") + } + + @Test func aMarkedLineEndsWithShowDiffAtThatLine() { + #expect(ContextActions.entries(for: .editor(reference: reference, code: nil, showDiffLine: 12)) == [ + .action(.passOnReference("src/a.php:12", code: nil), label: "Pass on reference"), + .action(.copyReference("src/a.php:12"), label: "Copy reference"), + .separator, + .action(.showDiff("src/a.php", line: 12), label: "Show diff"), + ]) + } + + @Test func anUnchangedLineHasNoShowDiff() { + #expect(ContextActions.entries(for: .editor(reference: reference, code: nil)) == [ + .action(.passOnReference("src/a.php:12", code: nil), label: "Pass on reference"), + .action(.copyReference("src/a.php:12"), label: "Copy reference"), + ]) + } +} + +@Suite struct BouwenContextMenuTests { + private func hasBouwen(_ target: ContextTarget) -> Bool { + ContextActions.entries(for: target).contains { entry in + guard case .action(.bouwen, _) = entry else { return false } + return true + } + } + + @Test func anOntwikkelingFolderStartsWithBouwen() { + let entries = ContextActions.entries(for: .directory(path: "ontwikkelingen/2026-10-02-001-x")) + #expect(Array(entries.prefix(3)) == [ + .action(.bouwen("2026-10-02-001-x"), label: "Bouwen"), + .separator, + .action(.passOnReference("ontwikkelingen/2026-10-02-001-x/", code: nil), label: "Pass on reference"), + ]) + } + + @Test func otherPathsHaveNoBouwen() { + #expect(!hasBouwen(.directory(path: "ontwikkelingen"))) + #expect(!hasBouwen(.directory(path: "ontwikkelingen/ontwikkeld"))) + #expect(!hasBouwen(.directory(path: "ontwikkelingen/a/b"))) + #expect(!hasBouwen(.directory(path: "src/ontwikkelingen/a"))) + #expect(!hasBouwen(.file(path: "ontwikkelingen/a"))) } } diff --git a/Tests/HelderUITests/Editor/CodeEditorShowDiffTests.swift b/Tests/HelderUITests/Editor/CodeEditorShowDiffTests.swift new file mode 100644 index 0000000..becd9b8 --- /dev/null +++ b/Tests/HelderUITests/Editor/CodeEditorShowDiffTests.swift @@ -0,0 +1,57 @@ +import AppKit +import HelderCore +@testable import HelderUI +import Testing + +@MainActor +@Suite struct CodeEditorShowDiffTests { + /// Line 2 is a blank added line, line 3 a changed one; lines 1 and 4 are unchanged. + private func open(offersShowDiff: Bool = true) -> (CodeEditorController, NSWindow) { + let controller = CodeEditorController() + let window = NSWindow(contentRect: NSRect(x: 0, y: 0, width: 700, height: 400), styleMask: [.titled], + backing: .buffered, defer: false) + window.contentView = controller.scrollView + let marks = [2: CodeLineMark(tint: true, tone: .added), 3: CodeLineMark(tint: true, tone: .added)] + controller.apply(CodeEditorConfiguration(documentID: "a.php", path: "a.php", text: "one\n\nthree\nfour", revision: 1, + language: nil, isEditable: true, wrap: false, tabSize: 4, marksKey: "m", makeMarks: { marks }, + offersShowDiff: offersShowDiff, knownSymbols: [], symbolsVersion: 0, flash: nil, focusRequest: 0, + selectAllRequest: 0, fontScale: 1, isShown: true)) + window.displayIfNeeded() + return (controller, window) + } + + /// A window point inside the first row of `line`, `x` points from the text view's left edge. + private func point(line: Int, x: CGFloat, in controller: CodeEditorController) -> NSPoint { + var rect: NSRect? + controller.forEachRow(in: controller.textView.bounds) { row in + if row.line == line, rect == nil { rect = row.rect } + } + let row = rect ?? .zero + return controller.textView.convert(NSPoint(x: x, y: row.midY), to: nil) + } + + @Test func aBlankAddedLineOffersShowDiff() { + let (controller, window) = open() + #expect(controller.showDiffLine(atWindowPoint: point(line: 2, x: 40, in: controller)) == 2) + withExtendedLifetime(window) {} + } + + @Test func theSpaceAfterTheLastGlyphCounts() { + let (controller, window) = open() + #expect(controller.showDiffLine(atWindowPoint: point(line: 3, x: 500, in: controller)) == 3) + withExtendedLifetime(window) {} + } + + @Test func anUnchangedLineOffersNothing() { + let (controller, window) = open() + #expect(controller.showDiffLine(atWindowPoint: point(line: 1, x: 10, in: controller)) == nil) + #expect(controller.showDiffLine(atWindowPoint: point(line: 4, x: 500, in: controller)) == nil) + withExtendedLifetime(window) {} + } + + @Test func aFileWithoutShowDiffOffersNothingOnAMarkedLine() { + let (controller, window) = open(offersShowDiff: false) + #expect(controller.showDiffLine(atWindowPoint: point(line: 3, x: 10, in: controller)) == nil) + withExtendedLifetime(window) {} + } +} diff --git a/Tests/HelderUITests/Editor/EditorLayoutTests.swift b/Tests/HelderUITests/Editor/EditorLayoutTests.swift index 772c245..3f02997 100644 --- a/Tests/HelderUITests/Editor/EditorLayoutTests.swift +++ b/Tests/HelderUITests/Editor/EditorLayoutTests.swift @@ -16,7 +16,17 @@ import Testing let view = EditorPresentation(path: "a.php", requested: nil, diff: makeDiff(original: "a", updated: "b")) #expect(view.mode == .actual) #expect(view.barButtons == [.diff]) - #expect(view.opensDiffOnClick) + #expect(view.offersShowDiff) + } + + @Test func anUnchangedFileOffersNoShowDiff() { + #expect(!EditorPresentation(path: "a.php", requested: nil, diff: nil).offersShowDiff) + } + + @Test func showDiffNeedsActualInThePane() { + let view = EditorPresentation(path: "README.md", requested: .preview, diff: makeDiff(original: "a", updated: "b")) + #expect(view.paneMode == .preview) + #expect(!view.offersShowDiff) } @Test func unchangedMarkdownOffersOnlyPreview() { @@ -55,11 +65,11 @@ import Testing #expect(view.paneMode == .actual) } - @Test func anAddedFileHasNoClickToDiff() { + @Test func anAddedFileOffersNoShowDiff() { let diff = makeDiff(original: "", updated: "b", isAddedFile: true) let actual = EditorPresentation(path: "a.php", requested: .actual, diff: diff) #expect(actual.placeholder == nil) - #expect(!actual.opensDiffOnClick) + #expect(!actual.offersShowDiff) #expect(actual.status == .added) } diff --git a/Tests/HelderUITests/Editor/EditorScrollOriginTests.swift b/Tests/HelderUITests/Editor/EditorScrollOriginTests.swift index 3e7cd81..99bb147 100644 --- a/Tests/HelderUITests/Editor/EditorScrollOriginTests.swift +++ b/Tests/HelderUITests/Editor/EditorScrollOriginTests.swift @@ -18,7 +18,7 @@ import Testing window.contentView = controller.scrollView controller.apply(CodeEditorConfiguration(documentID: "notes.md", path: "notes.md", text: Self.text, revision: 1, language: nil, isEditable: true, wrap: wrap, tabSize: 4, marksKey: "", makeMarks: { [:] }, - opensDiffOnClick: false, knownSymbols: [], symbolsVersion: 0, flash: nil, focusRequest: 0, + offersShowDiff: false, knownSymbols: [], symbolsVersion: 0, flash: nil, focusRequest: 0, selectAllRequest: 0, fontScale: 1, isShown: true)) return (controller, window) } diff --git a/Tests/HelderUITests/Editor/EditorStoreTests.swift b/Tests/HelderUITests/Editor/EditorStoreTests.swift index 0db9b12..e647bec 100644 --- a/Tests/HelderUITests/Editor/EditorStoreTests.swift +++ b/Tests/HelderUITests/Editor/EditorStoreTests.swift @@ -458,7 +458,7 @@ import Testing #expect(h.store.mode(for: "README.md") == .preview) } - @Test func aClickOnAMarkedLineOpensTheDiffOnHeadVersusDiskAtThatLine() { + @Test func showDiffOnAMarkedLineOpensTheDiffOnHeadVersusDiskAtThatLine() { let h = EditorHarness(files: ["a.php": "new"]) h.git.change("a.php", makeDiff(original: "old", updated: "new")) h.store.open("a.php", OpenOptions(side: .unstaged)) @@ -553,16 +553,29 @@ import Testing #expect(h.store.passOnSelectionRequest(anchor: .zero) == nil) } - @Test func theRightClickMenuIsPassOnThenCopyReference() { + @Test func theRightClickMenuIsPassOnThenCopyReferenceWithoutAHeader() { let h = EditorHarness(files: ["src/a.php": "x"]) let menu = h.store.contextMenuRequest(reference: AgentReference(path: "src/a.php", startLine: 42), code: nil, anchor: .zero) - #expect(menu.header == "src/a.php:42") + #expect(menu.header == "") #expect(menu.entries == [ .action(.passOnReference("src/a.php:42", code: nil), label: "Pass on reference"), .action(.copyReference("src/a.php:42"), label: "Copy reference"), ]) } + @Test func aMarkedLineAddsShowDiffBelowASeparator() { + let h = EditorHarness(files: ["src/a.php": "x"]) + let menu = h.store.contextMenuRequest(reference: AgentReference(path: "src/a.php", startLine: 42), code: nil, + showDiffLine: 42, anchor: .zero) + #expect(menu.header == "") + #expect(menu.entries == [ + .action(.passOnReference("src/a.php:42", code: nil), label: "Pass on reference"), + .action(.copyReference("src/a.php:42"), label: "Copy reference"), + .separator, + .action(.showDiff("src/a.php", line: 42), label: "Show diff"), + ]) + } + @Test func anEmptyNotePassesTheBareReference() { #expect(PassOn.compose(note: " ", reference: "src/a.php:42") == "src/a.php:42") } diff --git a/Tests/HelderUITests/Explorer/ExplorerStoreTests.swift b/Tests/HelderUITests/Explorer/ExplorerStoreTests.swift index dc8b91d..00b17b7 100644 --- a/Tests/HelderUITests/Explorer/ExplorerStoreTests.swift +++ b/Tests/HelderUITests/Explorer/ExplorerStoreTests.swift @@ -224,7 +224,7 @@ import Testing #expect(menuLabels(folderMenu) == ["Pass on reference", "Copy reference", "New file", "New folder", "Rename folder", "Show in Finder", "Delete folder"]) #expect(menuLabels(rootMenu) == ["New file", "Show in Finder"]) - #expect(folderMenu.header == "src/") + #expect(folderMenu.header.isEmpty) #expect(rootMenu.header == "console/") #expect(ExplorerStore.target(for: TreeRow(path: "src", kind: .directory, depth: 0)) == .directory(path: "src")) } diff --git a/Tests/HelderUITests/Overlays/ContextMenuTintTests.swift b/Tests/HelderUITests/Overlays/ContextMenuTintTests.swift index 323cd8b..1a23b7b 100644 --- a/Tests/HelderUITests/Overlays/ContextMenuTintTests.swift +++ b/Tests/HelderUITests/Overlays/ContextMenuTintTests.swift @@ -19,10 +19,16 @@ import Testing @Test func passOnOpenDiffAndRenameAreGrey() { #expect(ContextMenuOverlay.tint(for: .passOnReference("a.php", code: nil)) == .rename) #expect(ContextMenuOverlay.tint(for: .passOnFileName("a.php")) == .rename) + #expect(ContextMenuOverlay.tint(for: .bouwen("x")) == .rename) #expect(ContextMenuOverlay.tint(for: .openDiff("a.php")) == .rename) + #expect(ContextMenuOverlay.tint(for: .showDiff("a.php", line: 3)) == .rename) #expect(ContextMenuOverlay.tint(for: .rename("a.php", isDirectory: false)) == .rename) } + @Test func showDiffWearsTheOpenDiffIcon() { + #expect(ContextMenuOverlay.symbol(for: .showDiff("a.php", line: 3)) == ContextMenuOverlay.symbol(for: .openDiff("a.php"))) + } + @Test func copyReferenceKeepsThePlainIconThatTurnsAmberOnHighlight() { #expect(ContextMenuOverlay.tint(for: .copyReference("a.php")) == .plain) #expect(MenuIconTint.plain.color == nil) diff --git a/Tests/HelderUITests/State/WorkspaceModelTests.swift b/Tests/HelderUITests/State/WorkspaceModelTests.swift index e46268c..6f6dd04 100644 --- a/Tests/HelderUITests/State/WorkspaceModelTests.swift +++ b/Tests/HelderUITests/State/WorkspaceModelTests.swift @@ -391,6 +391,14 @@ import Testing #expect(harness.toastTitles == ["Passed to agent"]) } + @Test func bouwenInsertsTheCommandIntoTheAgent() async { + let harness = WorkspaceHarness() + await harness.start() + await harness.perform(.context(.bouwen("2026-10-02-001-x"))) + #expect(harness.agent.sent == [BracketedPaste.wrap("/bouwen 2026-10-02-001-x", composerHasText: false)]) + #expect(harness.toastTitles == ["Passed to agent"]) + } + @Test func aDirtyTabAsksBeforeItCloses() async { let harness = WorkspaceHarness(contents: ["a.php": "one"]) await harness.start() @@ -576,6 +584,14 @@ import Testing #expect(editor?.mode(for: "a.md") == .preview) } + @Test func showDiffOpensTheDiffOfTheOpenFileAtThatLine() async { + let harness = WorkspaceHarness(git: snapshot([("a.php", .modified, false)]), contents: ["a.php": "b"]) + await harness.start() + harness.model.open("a.php") + await harness.perform(.context(.showDiff("a.php", line: 3))) + #expect(harness.model.overlay.current == .diff(DiffOverlayRequest(path: "a.php", side: nil, focusLine: 3))) + } + @Test func theRecentProjectListLeavesOutTheOpenProject() async { let harness = WorkspaceHarness(recents: [RecentProject(path: "/elsewhere", name: "elsewhere")]) await harness.start() diff --git a/docs/behaviour.md b/docs/behaviour.md index 085923e..32517fb 100644 --- a/docs/behaviour.md +++ b/docs/behaviour.md @@ -135,7 +135,7 @@ All are presentations of the same file: A changed file opens on the live file, or on the Diff when `git.defaultDiffMode` is `diff`. -**On the live file, a click on a marked line opens the Diff.** The full-screen side-by-side view comes up on the pair of the whole file, HEAD against disk, and both panes scroll so that the clicked line sits in the middle of the window. A line near the start or the end of the file goes as near to the middle as the file permits. `Esc` returns to the live file. Hover does nothing, and there is no animation. A new file, where every line is marked, does not open the Diff on click. +**On the live file, Show diff in the right-click menu of a marked line opens the Diff.** A left click on a marked line places the caret like on any line. The full-screen side-by-side view comes up on the pair of the whole file, HEAD against disk, and both panes scroll so that the right-clicked line sits in the middle of the window. A line near the start or the end of the file goes as near to the middle as the file permits. `Esc` returns to the live file. Hover does nothing, and there is no animation. A new file, where every line is marked, offers no Show diff. Shared rules: teal is what the file holds now, amber-deep is what it held before. There is no green and no red anywhere. Syntax highlighting stays on in all modes. Line numbers follow `editor.lineNumbers` (default absolute). @@ -147,11 +147,13 @@ Shared rules: teal is what the file holds now, amber-deep is what it held before ### Right-click in code -Right-clicking inside the code area, with or without a selection, shows a context menu with exactly two items: +Right-clicking inside the code area, with or without a selection, shows a context menu without a header line, with two items: 1. **Copy reference**: copies a reference to the clicked location to the clipboard. With no selection it is path plus single line, for example `src/Http/Controller/UserController.php:42`. With a selection it is path plus start and end line, for example `src/Http/Controller/UserController.php:42-58`. The path is project-relative. 2. **Pass on to Agent**: opens a small inline input popup anchored near the click or selection, with a single optional text field. On confirm (`Enter`), it composes one line, the typed text followed by the same reference, and inserts it into the agent pane's input. The insert does **not** submit. It lands as a new, unsubmitted line and the cursor sits on a fresh line, so the action can be repeated to stack several references before the user sends. `Esc` cancels with no insert. An empty field passes the bare reference. +On a marked line of the live file (any marked line, blank lines and the space after the text included), a separator and a third item follow: **Show diff**, which opens the Diff centred on that line. A new file, Preview and the Diff's own menu have no Show diff. + ### File-state behavior in the views - **Added file**: only the current content exists. The live file marks every line as added, and Diff shows an empty left pane with the file on the right. diff --git a/docs/guide/file-view-diff.md b/docs/guide/file-view-diff.md index 8af2435..d699097 100644 --- a/docs/guide/file-view-diff.md +++ b/docs/guide/file-view-diff.md @@ -33,9 +33,9 @@ The Diff is a full-screen, side-by-side comparison of a changed file. It covers ### Open the Diff - Click **Diff** in the [file view](file-view.md) bar. The button shows only on a file with git changes. -- Click a marked (teal) line in the file view. The Diff opens centred on that line. +- Right-click a marked (teal) line in the file view and choose **Show diff**. The Diff opens centred on that line. - Right-click a row in [Git](git.md) and choose **Open diff**. -- A file you open from a Git row remembers that row. The **Diff** button then shows that row's half (staged or unstaged). A click on a marked line always compares the last commit with the file on disk. +- A file you open from a Git row remembers that row. The **Diff** button then shows that row's half (staged or unstaged). Show diff on a marked line always compares the last commit with the file on disk. ### Layout - The Diff covers all columns. The window's shortcuts still work over it. @@ -94,7 +94,7 @@ The Diff is a full-screen, side-by-side comparison of a changed file. It covers ## Related -- [File view](file-view.md): the live view with teal line marks, where a click opens the Diff. +- [File view](file-view.md): the live view with teal line marks, where **Show diff** opens the Diff. - [Git](git.md): the changes, the staged and unstaged halves, and **Open diff**. - [Pass on to Agent](pass-on-to-agent.md): the reference format and the prompt. - [Right-click menu](right-click-menu.md): the menus across Helder. diff --git a/docs/guide/file-view.md b/docs/guide/file-view.md index 84a79b1..30c8101 100644 --- a/docs/guide/file-view.md +++ b/docs/guide/file-view.md @@ -45,8 +45,8 @@ The file view is the third column (Col C), between the [Explorer](explorer.md) a - Teal tint, teal left rule and teal line number: a line the file holds now that is new or edited. - A thin amber-deep rule on the top edge of a line: lines were removed just above it. At the end of the file the rule sits under the last line. - Removed lines never show inline. To see them, open the [Diff](file-view-diff.md). -- Click a marked line (a plain click, no drag) to open the Diff centred on that line. -- In a new file every line is teal, so a click there does not open the Diff. +- Right-click a marked line and choose **Show diff** to open the Diff centred on that line. A left click places the caret, as on any line. +- In a new file every line is teal, so its menu has no Show diff. - The marks follow your edits once git sees the saved file. ### Edit and save diff --git a/docs/guide/keyboard-shortcuts.md b/docs/guide/keyboard-shortcuts.md index 39a97b2..3508c4c 100644 --- a/docs/guide/keyboard-shortcuts.md +++ b/docs/guide/keyboard-shortcuts.md @@ -123,7 +123,7 @@ See [File view](file-view.md), [Markdown](file-view-markdown.md) and [Code symbo | `Cmd+click` on a PHP class name | Show its declaration and references | | Click a line number | Select that line | | `Shift+click` a line number | Extend the selection to that line | -| Click a marked (changed) line | Open the Diff at that line | +| Right-click a marked (changed) line, **Show diff** | Open the Diff at that line | ### Recent files list See [Go to file](go-to-file.md). diff --git a/docs/guide/pass-on-to-agent.md b/docs/guide/pass-on-to-agent.md index 1f56b8d..eaa3c6c 100644 --- a/docs/guide/pass-on-to-agent.md +++ b/docs/guide/pass-on-to-agent.md @@ -7,33 +7,31 @@ Pass on to Agent sends a pointer to your code to the [Claude Code](claude-code.m ## At a glance ```text - app/Http/UserController.php:42-45 (1) menu header +--------------------------------------+ - | * Pass on selection | (2) - | Copy reference | (3) + | * Pass on selection | (1) + | Copy reference | (2) +--------------------------------------+ +----------------------------------------------+ - | * Pass on to agent [esc] | (4) + | * Pass on to agent [esc] | (3) | +------------------------------------------+ | - | | Add a note (optional)... | | (5) + | | Add a note (optional)... | | (4) | +------------------------------------------+ | - | Inserts [ check the eager load app/Http/ ] | (6) + | Inserts [ check the eager load app/Http/ ] | (5) | [ UserController.php:42-45 ] | | [ ``` ] | | [ $user->load('roles'); ] | | [ ``` ] | - | (enter) insert into agent (esc) cancel | (7) + | (enter) insert into agent (esc) cancel | (6) +----------------------------------------------+ ``` -1. **Header**: the reference the menu acts on. -2. **Pass on**: "Pass on selection" with text selected, else "Pass on reference". Opens the prompt. -3. **Copy reference**: copies the reference to the clipboard. -4. **Prompt title**: marked with the amber spark that marks every pass-on action. -5. **Note field**: an optional note. The keyboard starts here. -6. **Inserts**: a live preview of the exact text that goes to the agent. -7. **Hints**: `Enter` inserts, `Esc` cancels. +1. **Pass on**: "Pass on selection" with text selected, else "Pass on reference". Opens the prompt. +2. **Copy reference**: copies the reference to the clipboard. +3. **Prompt title**: marked with the amber spark that marks every pass-on action. +4. **Note field**: an optional note. The keyboard starts here. +5. **Inserts**: a live preview of the exact text that goes to the agent. +6. **Hints**: `Enter` inserts, `Esc` cancels. ## Features diff --git a/docs/guide/right-click-menu.md b/docs/guide/right-click-menu.md index 34ac8a4..536147a 100644 --- a/docs/guide/right-click-menu.md +++ b/docs/guide/right-click-menu.md @@ -21,7 +21,7 @@ Helder draws its own right-click menu, in the same dark style everywhere. This p +----------------------------------------+ ``` -1. **Header**: what you clicked: a path, a folder path ending in `/`, or a reference such as `src/app.php:42`. Terminal menus have no header. +1. **Header**: what you clicked: a path, or the project name ending in `/`. Folder, code, Diff and terminal menus have no header. 2. **Highlighted item**: an amber rule on the left. The first item is highlighted when the menu opens. 3. **Separator**: a thin line between groups of items. 4. **Destructive item**: Discard and Delete read in amber-deep, so they stand out. @@ -124,12 +124,10 @@ Right-click a file in the [Explorer](explorer.md). The header is the file's path ### Explorer: folder -Right-click a folder. The header is the folder's path with a trailing `/`. +Right-click a folder. This menu has no header. ```text +----------------------------------------+ -| app/Http/ | -|----------------------------------------| | * Pass on reference | | # Copy reference | |----------------------------------------| @@ -148,6 +146,20 @@ Right-click a folder. The header is the folder's path with a trailing `/`. - **Rename folder**: opens the name prompt with the current name. - **Delete folder**: always asks first. The folder and everything inside it are deleted for good. +A folder directly inside the top-level `ontwikkelingen/` folder gets one extra group at the top. The archive folder `ontwikkelingen/ontwikkeld/` and deeper folders do not. + +```text ++----------------------------------------+ +| T Bouwen | +|----------------------------------------| +| * Pass on reference | +| # Copy reference | +| ... | ++----------------------------------------+ +``` + +- **Bouwen**: inserts `/bouwen ` into the [Claude Code](claude-code.md) input, not sent. For example `/bouwen 2026-10-02-001-stats`. A [notification](notifications.md) says `Passed to agent`. + ### Explorer: empty space Right-click the empty space under the rows of the [Explorer](explorer.md). It stands for the project folder. The header is the project name with a trailing `/`. @@ -168,7 +180,7 @@ There is no New folder here. Type `name/file` in New file, or right-click an exi ### Code in the file view -Right-click in the code of the [File view](file-view.md). The header is the reference: +Right-click in the code of the [File view](file-view.md). This menu has no header. The items use the reference: - No selection: the path and the line you clicked, for example `src/app.php:42`. - With a selection: the path and the first and last selected line, for example `src/app.php:42-58`. @@ -177,8 +189,6 @@ Without a selection: ```text +----------------------------------------+ -| src/Http/UserController.php:42 | -|----------------------------------------| | * Pass on reference | | # Copy reference | +----------------------------------------+ @@ -188,25 +198,33 @@ With a selection: ```text +----------------------------------------+ -| src/Http/UserController.php:42-58 | -|----------------------------------------| | * Pass on selection | | # Copy reference | +----------------------------------------+ ``` +On a marked (teal) line of a changed file: + +```text ++----------------------------------------+ +| * Pass on reference | +| # Copy reference | +|----------------------------------------| +| <> Show diff | ++----------------------------------------+ +``` + - **Pass on selection** passes the reference and the selected code. See [Pass on to Agent](pass-on-to-agent.md). +- **Show diff** opens the full-screen [Diff](file-view-diff.md) of the file, centred on the line you right-clicked. Every marked line counts, a blank one and the space after the text included. A new file, where every line is marked, has no Show diff. A left click on a marked line only places the caret. - The same menu shows on the rendered [Markdown preview](file-view-markdown.md) and on an image. There it refers to the file's first line, for example `README.md:1`. - `Cmd+Right` with code selected opens the Pass on prompt straight away, without the menu. ### Diff -Right-click a line in the full-screen [Diff](file-view-diff.md). The menu stays inside the Diff. +Right-click a line in the full-screen [Diff](file-view-diff.md). The menu stays inside the Diff. It has no header and no Show diff. ```text +----------------------------------------+ -| src/Http/UserController.php:42 | -|----------------------------------------| | * Pass on reference | | # Copy reference | +----------------------------------------+ @@ -266,5 +284,5 @@ Delete file and Delete folder always ask; no setting turns that off. - [Pass on to Agent](pass-on-to-agent.md): what happens after a Pass on item. - [Git](git.md): the rows behind the git menus. - [Explorer](explorer.md): the rows behind the file, folder and empty-space menus. -- [File view: Diff](file-view-diff.md): where Open diff leads. +- [File view: Diff](file-view-diff.md): where Open diff and Show diff lead. - [Notifications](notifications.md): the confirmations after Copy and file actions.