Skip to content

Commit 27780d1

Browse files
committed
Remove 'Open original' and 'Opeb Changed' commands
1 parent 02a0435 commit 27780d1

3 files changed

Lines changed: 11 additions & 48 deletions

File tree

‎README.md‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ Use `--` before paths beginning with a hyphen. `--help` prints usage.
143143

144144
## Reviewing a Git repository
145145

146-
Choose **Open → Open Repository…** from the folder menu in the window toolbar, or **File → Open Repository…** (⌥⌘O), then select your project folder. Git must be available at `/usr/bin/git` (provided by Apple’s command-line developer tools).
146+
Choose **Open Repository…** from the folder button in the window toolbar, or **File → Open Repository…** (⌥⌘O), then select your project folder. Git must be available at `/usr/bin/git` (provided by Apple’s command-line developer tools).
147147

148148
- **Last commit** is selected by default. The panes compare the latest commit with its parent, using committed contents on both sides.
149149
- Open the commit picker to browse earlier commits. Search by commit message or a short/full hash; use **Load more commits** to browse further back. Message searches cover the current HEAD’s history, including commit bodies. A hash can also locate another commit available in the repository.
@@ -158,7 +158,7 @@ Repository review is read-only and commits-only. Staged, unstaged, and untracked
158158

159159
## Comparing text
160160

161-
- Use **File → Open Original… / Open Changed…**, the toolbar’s folder menu, or the **…** menu in each pane header to open files. You can also drop one file onto each text pane or header. Dropping onto a pane loads that side, including before a comparison starts and in the blank space below short files.
161+
- Drop one file onto each text pane or header. Dropping onto a pane loads that side, including before a comparison starts and in the blank space below short files.
162162
- Use the **Edit** menu or a pane’s **…** menu to **Paste** text into either side or **Edit** a snippet. An explicitly empty input can be compared too.
163163
- **Copy Text** in each pane’s **…** menu (or the **Edit** menu) copies the complete source text, without line numbers or display formatting. Repository headers have a copy icon.
164164
- Drag to select any range of text within either diff pane, across lines and wrapped rows. Shift-click and keyboard selection work too; **⌘A** selects that side and **⌘C** copies the selection. Copied selections preserve source tabs and line endings, without line numbers, change markers, or alignment gaps.
@@ -177,7 +177,6 @@ When both files have the same name, the headers include enough parent folders to
177177
| Action | Shortcut |
178178
| --- | --- |
179179
| New comparison | ⌘N |
180-
| Open original / changed | ⌘O / ⇧⌘O |
181180
| Paste original / changed | ⇧⌘V / ⌥⌘V |
182181
| Previous / next change | ⌘[ / ⌘] |
183182
| Swap | ⌥⌘S |

‎Sources/MacDiff/ComparisonCommands.swift‎

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
#if os(macOS)
22
import SwiftUI
33

4-
/// Window-owned actions keep file importers and editors in the comparison view,
4+
/// Window-owned actions keep text input and editing in the comparison view,
55
/// while their commands remain available in the menu bar and via shortcuts.
66
struct ComparisonActions {
7-
var open: (Bool) -> Void
87
var paste: (Bool) -> Void
98
var edit: (Bool) -> Void
109
var copy: (Bool) -> Void
@@ -33,12 +32,6 @@ struct ComparisonCommands: Commands {
3332
Button("New") { document.clear() }
3433
.keyboardShortcut("n", modifiers: .command)
3534
Divider()
36-
Button("Open Original…") { actions?.open(true) }
37-
.keyboardShortcut("o", modifiers: .command)
38-
.disabled(actions?.canChangeInputs != true)
39-
Button("Open Changed…") { actions?.open(false) }
40-
.keyboardShortcut("o", modifiers: [.command, .shift])
41-
.disabled(actions?.canChangeInputs != true)
4235
Button("Open Repository…") { document.chooseRepository() }
4336
.keyboardShortcut("o", modifiers: [.command, .option])
4437
Divider()

‎Sources/MacDiff/ContentView.swift‎

Lines changed: 8 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,10 @@
11
#if os(macOS)
22
import AppKit
33
import SwiftUI
4-
import UniformTypeIdentifiers
54
import DiffCore
65

76
struct ContentView: View {
87
@ObservedObject var document: DiffDocument
9-
@State private var choosingLeft = true
10-
@State private var showingImporter = false
11-
@State private var importDirectory = URL.documentsDirectory
128
@State private var editorInput: EditorInput?
139
@State private var loadedLaunchInputs = false
1410
@AppStorage("diffFontSize") private var fontSize = AppTypography.defaultDiffSize
@@ -36,22 +32,10 @@ struct ContentView: View {
3632
.preferredColorScheme(appearance == "dark" ? .dark : appearance == "light" ? .light : nil)
3733
.toolbar { windowToolbar }
3834
.focusedSceneValue(\.comparisonActions, ComparisonActions(
39-
open: open, paste: paste, edit: edit, copy: copy,
40-
canChangeInputs: !document.isRepositoryMode && editorInput == nil && !showingImporter
35+
paste: paste, edit: edit, copy: copy,
36+
canChangeInputs: !document.isRepositoryMode && editorInput == nil
4137
))
4238
.task { loadLaunchInputs() }
43-
.fileImporter(isPresented: $showingImporter, allowedContentTypes: [.data]) { result in
44-
switch result {
45-
case let .success(url):
46-
importDirectory = url.deletingLastPathComponent()
47-
document.load(url, onLeft: choosingLeft)
48-
case let .failure(error):
49-
if (error as NSError).code != NSUserCancelledError {
50-
document.errorMessage = error.localizedDescription
51-
}
52-
}
53-
}
54-
.fileDialogDefaultDirectory(importDirectory)
5539
.alert("Unable to use this input", isPresented: Binding(
5640
get: { document.errorMessage != nil },
5741
set: { if !$0 { document.errorMessage = nil } }
@@ -149,18 +133,11 @@ struct ContentView: View {
149133
@ToolbarContentBuilder
150134
private var windowToolbar: some ToolbarContent {
151135
ToolbarItem(placement: .navigation) {
152-
Menu {
153-
Button("Open Original…") { open(onLeft: true) }
154-
.disabled(document.isRepositoryMode)
155-
Button("Open Changed…") { open(onLeft: false) }
156-
.disabled(document.isRepositoryMode)
157-
Divider()
158-
Button("Open Repository…") { document.chooseRepository() }
159-
} label: {
160-
Label("Open", systemImage: "folder")
136+
Button { document.chooseRepository() } label: {
137+
Label("Open Repository…", systemImage: "folder")
161138
}
162-
.accessibilityLabel("Open")
163-
.help("Open files or a Git repository")
139+
.accessibilityLabel("Open Repository")
140+
.help("Open a Git repository (⌥⌘O)")
164141
}
165142
ToolbarItemGroup(placement: .primaryAction) {
166143
if document.isRepositoryMode {
@@ -215,7 +192,6 @@ struct ContentView: View {
215192
ProgressView().controlSize(.small).accessibilityLabel("Loading \(title.lowercased())")
216193
}
217194
Menu {
218-
Button("Open File…") { open(onLeft: onLeft) }
219195
Button("Paste Text") { paste(onLeft: onLeft) }
220196
Button("Edit Text…") { edit(onLeft: onLeft) }
221197
Divider()
@@ -228,7 +204,7 @@ struct ContentView: View {
228204
.menuStyle(.borderlessButton)
229205
.menuIndicator(.hidden)
230206
.fixedSize()
231-
.help("Open, paste, edit, or copy \(title.lowercased()) text")
207+
.help("Paste, edit, or copy \(title.lowercased()) text")
232208
}
233209
.padding(.horizontal, 16)
234210
.frame(maxWidth: .infinity, maxHeight: .infinity)
@@ -247,7 +223,7 @@ struct ContentView: View {
247223
Text("Compare two versions").font(.title2.weight(.semibold))
248224
Text("Add an original and a changed version to see what’s different.")
249225
.foregroundStyle(.secondary)
250-
Text("Open two files, drop them onto either text pane, or paste text from the clipboard.")
226+
Text("Drop a file onto each text pane, or paste text from the clipboard.")
251227
.font(AppTypography.body).foregroundStyle(.secondary)
252228
}
253229
HStack(alignment: .top, spacing: 20) {
@@ -350,11 +326,6 @@ struct ContentView: View {
350326
}
351327
}
352328

353-
private func open(onLeft: Bool) {
354-
choosingLeft = onLeft
355-
showingImporter = true
356-
}
357-
358329
private func loadDroppedFile(_ urls: [URL], onLeft: Bool) -> Bool {
359330
guard !document.isRepositoryMode, urls.count == 1, let url = urls.first, url.isFileURL else { return false }
360331
document.load(url, onLeft: onLeft)

0 commit comments

Comments
 (0)