@@ -468,6 +468,8 @@ impl Document {
468
468
469
469
let language_server = self . language_server . clone ( ) ;
470
470
471
+ // ensure changes are commited
472
+ self . commit_pending_changes ( None ) ;
471
473
// mark changes up to now as saved
472
474
self . reset_modified ( ) ;
473
475
@@ -831,6 +833,10 @@ impl Document {
831
833
832
834
/// Commit pending changes to history
833
835
pub fn append_changes_to_history ( & mut self , view_id : ViewId ) {
836
+ self . commit_pending_changes ( Some ( view_id) )
837
+ }
838
+
839
+ fn commit_pending_changes ( & mut self , view_id : Option < ViewId > ) {
834
840
if self . changes . is_empty ( ) {
835
841
return ;
836
842
}
@@ -839,8 +845,10 @@ impl Document {
839
845
let changes = std:: mem:: replace ( & mut self . changes , new_changeset) ;
840
846
// Instead of doing this messy merge we could always commit, and based on transaction
841
847
// annotations either add a new layer or compose into the previous one.
842
- let transaction =
843
- Transaction :: from ( changes) . with_selection ( self . selection ( view_id) . clone ( ) ) ;
848
+ let mut transaction = Transaction :: from ( changes) ;
849
+ if let Some ( view_id) = view_id {
850
+ transaction = transaction. with_selection ( self . selection ( view_id) . clone ( ) ) ;
851
+ }
844
852
845
853
// HAXX: we need to reconstruct the state as it was before the changes..
846
854
let old_state = self . old_state . take ( ) . expect ( "no old_state available" ) ;
0 commit comments