mirror of
https://github.com/sourcegit-scm/sourcegit
synced 2025-05-23 13:14:59 +00:00
enhance: remember last view mode in file histories view
Signed-off-by: leo <longshuang@msn.cn>
This commit is contained in:
parent
dacbd2a791
commit
e9297096df
2 changed files with 8 additions and 20 deletions
|
@ -36,22 +36,13 @@ namespace SourceGit.ViewModels
|
||||||
set => SetProperty(ref _viewContent, value);
|
set => SetProperty(ref _viewContent, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
public FileHistoriesSingleRevision(Repository repo, string file, Models.Commit revision, object prev)
|
public FileHistoriesSingleRevision(Repository repo, string file, Models.Commit revision, bool prevIsDiffMode)
|
||||||
{
|
{
|
||||||
_repo = repo;
|
_repo = repo;
|
||||||
_file = file;
|
_file = file;
|
||||||
_revision = revision;
|
_revision = revision;
|
||||||
|
_isDiffMode = prevIsDiffMode;
|
||||||
if (prev is FileHistoriesSingleRevision singleRevision)
|
_viewContent = null;
|
||||||
{
|
|
||||||
_isDiffMode = singleRevision._isDiffMode;
|
|
||||||
_viewContent = singleRevision._viewContent;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
_isDiffMode = true;
|
|
||||||
_viewContent = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
RefreshViewContent();
|
RefreshViewContent();
|
||||||
}
|
}
|
||||||
|
@ -283,13 +274,13 @@ namespace SourceGit.ViewModels
|
||||||
|
|
||||||
SelectedCommits.CollectionChanged += (_, _) =>
|
SelectedCommits.CollectionChanged += (_, _) =>
|
||||||
{
|
{
|
||||||
|
if (_viewContent is FileHistoriesSingleRevision singleRevision)
|
||||||
|
_prevIsDiffMode = singleRevision.IsDiffMode;
|
||||||
|
|
||||||
switch (SelectedCommits.Count)
|
switch (SelectedCommits.Count)
|
||||||
{
|
{
|
||||||
case 0:
|
|
||||||
ViewContent = new Models.Null();
|
|
||||||
break;
|
|
||||||
case 1:
|
case 1:
|
||||||
ViewContent = new FileHistoriesSingleRevision(_repo, _file, SelectedCommits[0], _viewContent);
|
ViewContent = new FileHistoriesSingleRevision(_repo, _file, SelectedCommits[0], _prevIsDiffMode);
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
ViewContent = new FileHistoriesCompareRevisions(_repo, _file, SelectedCommits[0], SelectedCommits[1]);
|
ViewContent = new FileHistoriesCompareRevisions(_repo, _file, SelectedCommits[0], SelectedCommits[1]);
|
||||||
|
@ -309,6 +300,7 @@ namespace SourceGit.ViewModels
|
||||||
private readonly Repository _repo = null;
|
private readonly Repository _repo = null;
|
||||||
private readonly string _file = null;
|
private readonly string _file = null;
|
||||||
private bool _isLoading = true;
|
private bool _isLoading = true;
|
||||||
|
private bool _prevIsDiffMode = true;
|
||||||
private List<Models.Commit> _commits = null;
|
private List<Models.Commit> _commits = null;
|
||||||
private object _viewContent = null;
|
private object _viewContent = null;
|
||||||
}
|
}
|
||||||
|
|
|
@ -109,10 +109,6 @@
|
||||||
|
|
||||||
<ContentControl Grid.Column="2" Content="{Binding ViewContent}">
|
<ContentControl Grid.Column="2" Content="{Binding ViewContent}">
|
||||||
<ContentControl.DataTemplates>
|
<ContentControl.DataTemplates>
|
||||||
<DataTemplate DataType="m:Null">
|
|
||||||
<Border/>
|
|
||||||
</DataTemplate>
|
|
||||||
|
|
||||||
<DataTemplate DataType="vm:FileHistoriesSingleRevision">
|
<DataTemplate DataType="vm:FileHistoriesSingleRevision">
|
||||||
<Grid RowDefinitions="Auto,*,Auto">
|
<Grid RowDefinitions="Auto,*,Auto">
|
||||||
<StackPanel Grid.Row="0" Margin="0,8" Height="28" HorizontalAlignment="Center" Orientation="Horizontal">
|
<StackPanel Grid.Row="0" Margin="0,8" Height="28" HorizontalAlignment="Center" Orientation="Horizontal">
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue