Merge #8054
8054: Item movers r=matklad a=ivan770 Closes #6823 https://user-images.githubusercontent.com/14003886/111331579-b4f43480-8679-11eb-9af0-e4dabacc4923.mp4 Implementation issues: - [ ] Most of items are non-movable, since _movability_ of any item has to be determined manually. Common ones are movable though - [x] Cursor should move with the item Co-authored-by: ivan770 <leshenko.ivan770@gmail.com>
This commit is contained in:
@@ -1427,6 +1427,25 @@ pub(crate) fn handle_open_cargo_toml(
|
||||
Ok(Some(res))
|
||||
}
|
||||
|
||||
pub(crate) fn handle_move_item(
|
||||
snap: GlobalStateSnapshot,
|
||||
params: lsp_ext::MoveItemParams,
|
||||
) -> Result<Option<lsp_types::TextDocumentEdit>> {
|
||||
let _p = profile::span("handle_move_item");
|
||||
let file_id = from_proto::file_id(&snap, ¶ms.text_document.uri)?;
|
||||
let range = from_proto::file_range(&snap, params.text_document, params.range)?;
|
||||
|
||||
let direction = match params.direction {
|
||||
lsp_ext::MoveItemDirection::Up => ide::Direction::Up,
|
||||
lsp_ext::MoveItemDirection::Down => ide::Direction::Down,
|
||||
};
|
||||
|
||||
match snap.analysis.move_item(range, direction)? {
|
||||
Some(text_edit) => Ok(Some(to_proto::text_document_edit(&snap, file_id, text_edit)?)),
|
||||
None => Ok(None),
|
||||
}
|
||||
}
|
||||
|
||||
fn to_command_link(command: lsp_types::Command, tooltip: String) -> lsp_ext::CommandLink {
|
||||
lsp_ext::CommandLink { tooltip: Some(tooltip), command }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user