Start work on applying LSP edits via a diff
Co-Authored-By: Antonio Scandurra <me@as-cii.com>
This commit is contained in:
parent
424b35253a
commit
3a1f9bb212
2 changed files with 101 additions and 16 deletions
|
@ -1585,17 +1585,23 @@ impl Project {
|
|||
)
|
||||
})
|
||||
.await?;
|
||||
let transaction = buffer_to_edit.update(&mut cx, |buffer, cx| {
|
||||
let edits = op.edits.into_iter().map(|edit| match edit {
|
||||
lsp::OneOf::Left(edit) => edit,
|
||||
lsp::OneOf::Right(edit) => edit.text_edit,
|
||||
});
|
||||
|
||||
let diff = buffer_to_edit
|
||||
.update(&mut cx, |buffer, cx| {
|
||||
let edits = op.edits.into_iter().map(|edit| match edit {
|
||||
lsp::OneOf::Left(edit) => edit,
|
||||
lsp::OneOf::Right(edit) => edit.text_edit,
|
||||
});
|
||||
buffer.diff_for_lsp_edits(edits, op.text_document.version, cx)
|
||||
})
|
||||
.await?;
|
||||
|
||||
let transaction = buffer_to_edit.update(&mut cx, |buffer, cx| {
|
||||
buffer.finalize_last_transaction();
|
||||
buffer.start_transaction();
|
||||
buffer
|
||||
.apply_lsp_edits(edits, op.text_document.version, cx)
|
||||
.log_err();
|
||||
if !buffer.apply_diff(diff, cx) {
|
||||
log::info!("buffer has changed since computing code action");
|
||||
}
|
||||
let transaction = if buffer.end_transaction(cx).is_some() {
|
||||
let transaction =
|
||||
buffer.finalize_last_transaction().unwrap().clone();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue