Skip to content

Commit c72506d

Browse files
committed
code_style: simplify the way detacting system preferred command key
Signed-off-by: leo <[email protected]>
1 parent d50b2c0 commit c72506d

File tree

3 files changed

+3
-6
lines changed

3 files changed

+3
-6
lines changed

src/Views/CommitMessageTextBox.axaml.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ private async void OnSubjectTextBoxPreviewKeyDown(object _, KeyEventArgs e)
125125
DescriptionEditor.CaretIndex = 0;
126126
e.Handled = true;
127127
}
128-
else if (e.Key == Key.V && ((OperatingSystem.IsMacOS() && e.KeyModifiers == KeyModifiers.Meta) || (!OperatingSystem.IsMacOS() && e.KeyModifiers == KeyModifiers.Control)))
128+
else if (e.Key == Key.V && e.KeyModifiers == (OperatingSystem.IsMacOS() ? KeyModifiers.Meta : KeyModifiers.Control))
129129
{
130130
e.Handled = true;
131131

src/Views/Histories.axaml.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -722,9 +722,7 @@ private void OnCommitListDoubleTapped(object sender, TappedEventArgs e)
722722

723723
private void OnCommitListKeyDown(object sender, KeyEventArgs e)
724724
{
725-
bool isSystemCmdKeyDown = (OperatingSystem.IsMacOS() && e.KeyModifiers.HasFlag(KeyModifiers.Meta)) ||
726-
(!OperatingSystem.IsMacOS() && e.KeyModifiers.HasFlag(KeyModifiers.Control));
727-
if (!isSystemCmdKeyDown)
725+
if (!e.KeyModifiers.HasFlag(OperatingSystem.IsMacOS() ? KeyModifiers.Meta : KeyModifiers.Control))
728726
return;
729727

730728
// These shortcuts are not mentioned in the Shortcut Reference window. Is this expected?

src/Views/Launcher.axaml.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,8 +115,7 @@ protected override void OnKeyDown(KeyEventArgs e)
115115
return;
116116
}
117117

118-
if ((OperatingSystem.IsMacOS() && e.KeyModifiers.HasFlag(KeyModifiers.Meta)) ||
119-
(!OperatingSystem.IsMacOS() && e.KeyModifiers.HasFlag(KeyModifiers.Control)))
118+
if (e.KeyModifiers.HasFlag(OperatingSystem.IsMacOS() ? KeyModifiers.Meta : KeyModifiers.Control))
120119
{
121120
if (e.Key == Key.W)
122121
{

0 commit comments

Comments
 (0)