Restore scroll after undo edit prediction (#31162)
Closes #29652 Release Notes: - Fixed an issue where the scroll and cursor position would not be restored after undoing an inline completion
This commit is contained in:
parent
ab017129d8
commit
0d7f4842f3
3 changed files with 111 additions and 3 deletions
|
@ -6523,6 +6523,10 @@ impl Editor {
|
|||
provider.accept(cx);
|
||||
}
|
||||
|
||||
// Store the transaction ID and selections before applying the edit
|
||||
let transaction_id_prev =
|
||||
self.buffer.read_with(cx, |b, cx| b.last_transaction_id(cx));
|
||||
|
||||
let snapshot = self.buffer.read(cx).snapshot(cx);
|
||||
let last_edit_end = edits.last().unwrap().0.end.bias_right(&snapshot);
|
||||
|
||||
|
@ -6531,9 +6535,20 @@ impl Editor {
|
|||
});
|
||||
|
||||
self.change_selections(None, window, cx, |s| {
|
||||
s.select_anchor_ranges([last_edit_end..last_edit_end])
|
||||
s.select_anchor_ranges([last_edit_end..last_edit_end]);
|
||||
});
|
||||
|
||||
let selections = self.selections.disjoint_anchors();
|
||||
if let Some(transaction_id_now) =
|
||||
self.buffer.read_with(cx, |b, cx| b.last_transaction_id(cx))
|
||||
{
|
||||
let has_new_transaction = transaction_id_prev != Some(transaction_id_now);
|
||||
if has_new_transaction {
|
||||
self.selection_history
|
||||
.insert_transaction(transaction_id_now, selections);
|
||||
}
|
||||
}
|
||||
|
||||
self.update_visible_inline_completion(window, cx);
|
||||
if self.active_inline_completion.is_none() {
|
||||
self.refresh_inline_completion(true, true, window, cx);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue