@@ -33,12 +33,6 @@ public string FileModeChange
3333 private set => SetProperty ( ref _fileModeChange , value ) ;
3434 }
3535
36- public bool IsLoading
37- {
38- get => _isLoading ;
39- private set => SetProperty ( ref _isLoading , value ) ;
40- }
41-
4236 public bool IsTextDiff
4337 {
4438 get => _isTextDiff ;
@@ -68,6 +62,7 @@ public DiffContext(string repo, Models.DiffOption option, DiffContext previous =
6862 _content = previous . _content ;
6963 _unifiedLines = previous . _unifiedLines ;
7064 _ignoreWhitespace = previous . _ignoreWhitespace ;
65+ _info = previous . _info ;
7166 }
7267
7368 if ( string . IsNullOrEmpty ( _option . OrgPath ) || _option . OrgPath == "/dev/null" )
@@ -109,7 +104,6 @@ private void LoadDiffContent()
109104 {
110105 Content = null ;
111106 IsTextDiff = false ;
112- IsLoading = false ;
113107 return ;
114108 }
115109
@@ -119,10 +113,14 @@ private void LoadDiffContent()
119113 // There is no way to tell a git-diff to use "ALL lines of context",
120114 // so instead we set a very high number for the "lines of context" parameter.
121115 var numLines = Preference . Instance . UseFullTextDiff ? 999999999 : _unifiedLines ;
122-
123116 var latest = new Commands . Diff ( _repo , _option , numLines , _ignoreWhitespace ) . Result ( ) ;
124- var rs = null as object ;
117+ var info = new Info ( _option , numLines , _ignoreWhitespace , latest ) ;
118+ if ( _info != null && info . IsSame ( _info ) )
119+ return ;
120+
121+ _info = info ;
125122
123+ var rs = null as object ;
126124 if ( latest . TextDiff != null )
127125 {
128126 var count = latest . TextDiff . Lines . Count ;
@@ -219,7 +217,6 @@ private void LoadDiffContent()
219217 FileModeChange = latest . FileModeChange ;
220218 Content = rs ;
221219 IsTextDiff = rs is Models . TextDiff ;
222- IsLoading = false ;
223220 } ) ;
224221 } ) ;
225222 }
@@ -252,14 +249,41 @@ private Models.RevisionSubmodule QuerySubmoduleRevision(string repo, string sha)
252249 ".ico" , ".bmp" , ".jpg" , ".png" , ".jpeg" , ".webp"
253250 } ;
254251
252+ private class Info
253+ {
254+ public string Argument { get ; set ; }
255+ public int UnifiedLines { get ; set ; }
256+ public bool IgnoreWhitespace { get ; set ; }
257+ public string OldHash { get ; set ; }
258+ public string NewHash { get ; set ; }
259+
260+ public Info ( Models . DiffOption option , int unifiedLines , bool ignoreWhitespace , Models . DiffResult result )
261+ {
262+ Argument = option . ToString ( ) ;
263+ UnifiedLines = unifiedLines ;
264+ IgnoreWhitespace = ignoreWhitespace ;
265+ OldHash = result . OldHash ;
266+ NewHash = result . NewHash ;
267+ }
268+
269+ public bool IsSame ( Info other )
270+ {
271+ return Argument . Equals ( other . Argument , StringComparison . Ordinal ) &&
272+ UnifiedLines == other . UnifiedLines &&
273+ IgnoreWhitespace == other . IgnoreWhitespace &&
274+ OldHash . Equals ( other . OldHash , StringComparison . Ordinal ) &&
275+ NewHash . Equals ( other . NewHash , StringComparison . Ordinal ) ;
276+ }
277+ }
278+
255279 private readonly string _repo ;
256280 private readonly Models . DiffOption _option = null ;
257281 private string _title ;
258282 private string _fileModeChange = string . Empty ;
259283 private int _unifiedLines = 4 ;
260- private bool _isLoading = true ;
261284 private bool _isTextDiff = false ;
262285 private bool _ignoreWhitespace = false ;
263286 private object _content = null ;
287+ private Info _info = null ;
264288 }
265289}
0 commit comments