Skip to content

Commit ceea4a1

Browse files
committed
refactor: commit message editor (#2096)
- When using `SourceGit` as standalone commit message editor, always quits with code `0`. - Use hotkey `ESC` and dialog titlebar button instead of a custom `OK` button to close this window.
1 parent 5f0bd16 commit ceea4a1

File tree

2 files changed

+8
-11
lines changed

2 files changed

+8
-11
lines changed

src/Views/CommitMessageEditor.axaml

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,10 @@
3737

3838
<StackPanel Grid.Row="1" Orientation="Vertical" Margin="8">
3939
<v:CommitMessageToolBox x:Name="Editor" Height="400"/>
40-
<Button Classes="flat primary"
41-
Width="80"
42-
Margin="0,8,0,4"
43-
Content="{DynamicResource Text.Sure}"
44-
Click="SaveAndClose"
45-
HorizontalAlignment="Center"/>
40+
<Button Width="0" Height="0"
41+
Margin="0" Padding="0"
42+
Click="OnCloseByHotKey"
43+
HotKey="Escape"/>
4644
</StackPanel>
4745
</Grid>
4846
</v:ChromelessWindow>

src/Views/CommitMessageEditor.axaml.cs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -60,19 +60,18 @@ protected override void OnClosed(EventArgs e)
6060
{
6161
base.OnClosed(e);
6262

63+
_onSave?.Invoke(Editor.CommitMessage);
64+
6365
if (_shouldExitApp)
64-
App.Quit(_exitCode);
66+
App.Quit(0);
6567
}
6668

67-
private void SaveAndClose(object _1, RoutedEventArgs _2)
69+
private void OnCloseByHotKey(object sender, RoutedEventArgs e)
6870
{
69-
_onSave?.Invoke(Editor.CommitMessage);
70-
_exitCode = 0;
7171
Close();
7272
}
7373

7474
private Action<string> _onSave = null;
7575
private bool _shouldExitApp = true;
76-
private int _exitCode = -1;
7776
}
7877
}

0 commit comments

Comments
 (0)