@@ -35,7 +35,7 @@ public bool CanSquashOrFixup
3535 public Models . InteractiveRebaseAction Action
3636 {
3737 get => _action ;
38- private set => SetProperty ( ref _action , value ) ;
38+ set => SetProperty ( ref _action , value ) ;
3939 }
4040
4141 public string Subject
@@ -68,11 +68,6 @@ public InteractiveRebaseItem(Models.Commit c, string message, bool canSquashOrFi
6868 CanSquashOrFixup = canSquashOrFixup ;
6969 }
7070
71- public void SetAction ( object param )
72- {
73- Action = ( Models . InteractiveRebaseAction ) param ;
74- }
75-
7671 private Models . InteractiveRebaseAction _action = Models . InteractiveRebaseAction . Pick ;
7772 private string _subject ;
7873 private string _fullMessage ;
@@ -158,10 +153,8 @@ public void MoveItemUp(InteractiveRebaseItem item)
158153 var prev = Items [ idx - 1 ] ;
159154 Items . RemoveAt ( idx - 1 ) ;
160155 Items . Insert ( idx , prev ) ;
161-
162- item . CanSquashOrFixup = true ;
163- prev . CanSquashOrFixup = idx < Items . Count - 1 ;
164156 SelectedItem = item ;
157+ UpdateItems ( ) ;
165158 }
166159 }
167160
@@ -173,11 +166,21 @@ public void MoveItemDown(InteractiveRebaseItem item)
173166 var next = Items [ idx + 1 ] ;
174167 Items . RemoveAt ( idx + 1 ) ;
175168 Items . Insert ( idx , next ) ;
176-
177- item . CanSquashOrFixup = idx < Items . Count - 2 ;
178- next . CanSquashOrFixup = true ;
179169 SelectedItem = item ;
170+ UpdateItems ( ) ;
171+ }
172+ }
173+
174+ public void ChangeAction ( InteractiveRebaseItem item , Models . InteractiveRebaseAction action )
175+ {
176+ if ( ! item . CanSquashOrFixup )
177+ {
178+ if ( action == Models . InteractiveRebaseAction . Squash || action == Models . InteractiveRebaseAction . Fixup )
179+ return ;
180180 }
181+
182+ item . Action = action ;
183+ UpdateItems ( ) ;
181184 }
182185
183186 public Task < bool > Start ( )
@@ -210,6 +213,27 @@ public Task<bool> Start()
210213 } ) ;
211214 }
212215
216+ private void UpdateItems ( )
217+ {
218+ if ( Items . Count == 0 )
219+ return ;
220+
221+ var hasValidParent = false ;
222+ for ( var i = Items . Count - 1 ; i >= 0 ; i -- )
223+ {
224+ var item = Items [ i ] ;
225+ if ( hasValidParent )
226+ {
227+ item . CanSquashOrFixup = true ;
228+ }
229+ else
230+ {
231+ item . CanSquashOrFixup = false ;
232+ hasValidParent = item . Action != Models . InteractiveRebaseAction . Drop ;
233+ }
234+ }
235+ }
236+
213237 private Repository _repo = null ;
214238 private bool _isLoading = false ;
215239 private InteractiveRebaseItem _selectedItem = null ;
0 commit comments