Skip to content

Commit 7fa1912

Browse files
committed
fix: hotkeys not work in change list (INFORMATION page)
Signed-off-by: leo <[email protected]>
1 parent 92fb4c8 commit 7fa1912

File tree

2 files changed

+32
-20
lines changed

2 files changed

+32
-20
lines changed

src/ViewModels/CommitDetail.cs

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,14 @@ public string GetAbsPath(string path)
246246
return Native.OS.GetAbsPath(_repo.FullPath, path);
247247
}
248248

249+
public void OpenChangeInMergeTool(Models.Change c)
250+
{
251+
var toolType = Preferences.Instance.ExternalMergeToolType;
252+
var toolPath = Preferences.Instance.ExternalMergeToolPath;
253+
var opt = new Models.DiffOption(_commit, c);
254+
new Commands.DiffTool(_repo.FullPath, toolType, toolPath, opt).Open();
255+
}
256+
249257
public ContextMenu CreateChangeContextMenuByFolder(ChangeTreeNode node, List<Models.Change> changes)
250258
{
251259
var fullPath = Native.OS.GetAbsPath(_repo.FullPath, node.FullPath);
@@ -335,10 +343,7 @@ public ContextMenu CreateChangeContextMenu(Models.Change change)
335343
openWithMerger.Tag = OperatingSystem.IsMacOS() ? "⌘+⇧+D" : "Ctrl+Shift+D";
336344
openWithMerger.Click += (_, ev) =>
337345
{
338-
var toolType = Preferences.Instance.ExternalMergeToolType;
339-
var toolPath = Preferences.Instance.ExternalMergeToolPath;
340-
var opt = new Models.DiffOption(_commit, change);
341-
new Commands.DiffTool(_repo.FullPath, toolType, toolPath, opt).Open();
346+
OpenChangeInMergeTool(change);
342347
ev.Handled = true;
343348
};
344349

src/Views/CommitDetail.axaml.cs

Lines changed: 23 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,29 @@ public CommitDetail()
1111
InitializeComponent();
1212
}
1313

14+
private async void OnCommitListKeyDown(object sender, KeyEventArgs e)
15+
{
16+
if (DataContext is ViewModels.CommitDetail detail &&
17+
sender is ListBox { SelectedItem: Models.Change change } &&
18+
e.KeyModifiers.HasFlag(OperatingSystem.IsMacOS() ? KeyModifiers.Meta : KeyModifiers.Control))
19+
{
20+
if (e.Key == Key.C)
21+
{
22+
var path = change.Path;
23+
if (e.KeyModifiers.HasFlag(KeyModifiers.Shift))
24+
path = detail.GetAbsPath(path);
25+
26+
await App.CopyTextAsync(path);
27+
e.Handled = true;
28+
}
29+
else if (e.Key == Key.D && e.KeyModifiers.HasFlag(KeyModifiers.Shift))
30+
{
31+
detail.OpenChangeInMergeTool(change);
32+
e.Handled = true;
33+
}
34+
}
35+
}
36+
1437
private void OnChangeDoubleTapped(object sender, TappedEventArgs e)
1538
{
1639
if (DataContext is ViewModels.CommitDetail detail && sender is Grid { DataContext: Models.Change change })
@@ -32,21 +55,5 @@ private void OnChangeContextRequested(object sender, ContextRequestedEventArgs e
3255

3356
e.Handled = true;
3457
}
35-
36-
private async void OnCommitListKeyDown(object sender, KeyEventArgs e)
37-
{
38-
if (DataContext is ViewModels.CommitDetail detail && sender is Grid { DataContext: Models.Change change })
39-
{
40-
if (e.Key == Key.C && e.KeyModifiers.HasFlag(OperatingSystem.IsMacOS() ? KeyModifiers.Meta : KeyModifiers.Control))
41-
{
42-
var path = change.Path;
43-
if (e.KeyModifiers.HasFlag(KeyModifiers.Shift))
44-
path = detail.GetAbsPath(path);
45-
46-
await App.CopyTextAsync(path);
47-
e.Handled = true;
48-
}
49-
}
50-
}
5158
}
5259
}

0 commit comments

Comments
 (0)