@@ -192,7 +192,7 @@ impl Document {
192192
193193 let success = transaction.changes().apply(&mut self.text);
194194
195− if !transaction.changes().is_empty() {
195+ if success {
196196 // update the selection: either take the selection specified in the transaction, or map the
197197 // current selection through changes.
198198 let selection = transaction
@@ -200,7 +200,9 @@ impl Document {
200200 .cloned()
201201 .unwrap_or_else(|| self.selection(view_id).clone().map(transaction.changes()));
202202 self.set_selection(view_id, selection);
203+ }
203204
205+ if !transaction.changes().is_empty() {
204206 self.version += 1;
205207
206208 // update tree-sitter syntax tree