diff --git a/src/Resources/Locales/en_US.axaml b/src/Resources/Locales/en_US.axaml index 879d81c9..c6999700 100644 --- a/src/Resources/Locales/en_US.axaml +++ b/src/Resources/Locales/en_US.axaml @@ -333,6 +333,7 @@ Restore windows Subject Guide Length Use fixed tab width in titlebar + Visible Diff Context Lines GIT Fetch remotes automatically Auto Fetch Interval diff --git a/src/Resources/Locales/zh_CN.axaml b/src/Resources/Locales/zh_CN.axaml index 2626b068..08855620 100644 --- a/src/Resources/Locales/zh_CN.axaml +++ b/src/Resources/Locales/zh_CN.axaml @@ -336,6 +336,7 @@ 启动时恢复上次打开的仓库 SUBJECT字数检测 使用固定宽度的标题栏标签 + DIFF上下文行数 GIT配置 启用定时自动拉取远程更新 自动拉取间隔 diff --git a/src/Resources/Locales/zh_TW.axaml b/src/Resources/Locales/zh_TW.axaml index 6d00ca4a..13717025 100644 --- a/src/Resources/Locales/zh_TW.axaml +++ b/src/Resources/Locales/zh_TW.axaml @@ -336,6 +336,7 @@ 啟動時恢復上次開啟的倉庫 SUBJECT字數檢測 使用固定寬度的標題欄標籤 + DIFF上下文行數 GIT配置 啟用定時自動拉取遠端更新 自動拉取間隔 diff --git a/src/ViewModels/DiffContext.cs b/src/ViewModels/DiffContext.cs index fc57788f..cb84e54d 100644 --- a/src/ViewModels/DiffContext.cs +++ b/src/ViewModels/DiffContext.cs @@ -57,16 +57,6 @@ namespace SourceGit.ViewModels private set => SetProperty(ref _content, value); } - public int Unified - { - get => _unified; - set - { - if (SetProperty(ref _unified, value)) - LoadDiffContent(); - } - } - public DiffContext(string repo, Models.DiffOption option, DiffContext previous = null) { _repo = repo; @@ -88,12 +78,20 @@ namespace SourceGit.ViewModels public void IncrUnified() { - Unified = _unified + 1; + var pref = Preference.Instance; + pref.DiffViewVisualLineNumbers = pref.DiffViewVisualLineNumbers + 1; + LoadDiffContent(); } public void DecrUnified() { - Unified = Math.Max(4, _unified - 1); + var pref = Preference.Instance; + var unified = pref.DiffViewVisualLineNumbers - 1; + if (pref.DiffViewVisualLineNumbers != unified) + { + pref.DiffViewVisualLineNumbers = unified; + LoadDiffContent(); + } } public void OpenExternalMergeTool() @@ -105,9 +103,10 @@ namespace SourceGit.ViewModels private void LoadDiffContent() { + var unified = Preference.Instance.DiffViewVisualLineNumbers; Task.Run(() => { - var latest = new Commands.Diff(_repo, _option, _unified).Result(); + var latest = new Commands.Diff(_repo, _option, unified).Result(); var rs = null as object; if (latest.TextDiff != null) @@ -238,6 +237,5 @@ namespace SourceGit.ViewModels private bool _isLoading = true; private bool _isTextDiff = false; private object _content = null; - private int _unified = 4; } } diff --git a/src/ViewModels/Preference.cs b/src/ViewModels/Preference.cs index 5a152f2d..edcbc7e1 100644 --- a/src/ViewModels/Preference.cs +++ b/src/ViewModels/Preference.cs @@ -194,6 +194,12 @@ namespace SourceGit.ViewModels set => SetProperty(ref _showHiddenSymbolsInDiffView, value); } + public int DiffViewVisualLineNumbers + { + get => _diffViewVisualLineNumbers; + set => SetProperty(ref _diffViewVisualLineNumbers, value); + } + public Models.ChangeViewMode UnstagedChangeViewMode { get => _unstagedChangeViewMode; @@ -550,6 +556,7 @@ namespace SourceGit.ViewModels private bool _useSyntaxHighlighting = false; private bool _enableDiffViewWordWrap = false; private bool _showHiddenSymbolsInDiffView = false; + private int _diffViewVisualLineNumbers = 4; private Models.ChangeViewMode _unstagedChangeViewMode = Models.ChangeViewMode.List; private Models.ChangeViewMode _stagedChangeViewMode = Models.ChangeViewMode.List; diff --git a/src/Views/DiffView.axaml b/src/Views/DiffView.axaml index ce96662c..3e421b31 100644 --- a/src/Views/DiffView.axaml +++ b/src/Views/DiffView.axaml @@ -34,11 +34,20 @@ - - diff --git a/src/Views/Preference.axaml b/src/Views/Preference.axaml index 2e8a04a3..56561c46 100644 --- a/src/Views/Preference.axaml +++ b/src/Views/Preference.axaml @@ -58,7 +58,7 @@ - + + + + - - + - - -