Skip to content

Commit

Permalink
Merge #8054
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
bors[bot] and ivan770 committed Mar 22, 2021
2 parents 3af1885 + d331155 commit d4fa672
Show file tree
Hide file tree
Showing 11 changed files with 781 additions and 1 deletion.
10 changes: 10 additions & 0 deletions crates/ide/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ mod hover;
mod inlay_hints;
mod join_lines;
mod matching_brace;
mod move_item;
mod parent_module;
mod references;
mod fn_references;
Expand Down Expand Up @@ -76,6 +77,7 @@ pub use crate::{
hover::{HoverAction, HoverConfig, HoverGotoTypeData, HoverResult},
inlay_hints::{InlayHint, InlayHintsConfig, InlayKind},
markup::Markup,
move_item::Direction,
prime_caches::PrimeCachesProgress,
references::{rename::RenameError, ReferenceSearchResult},
runnables::{Runnable, RunnableKind, TestId},
Expand Down Expand Up @@ -583,6 +585,14 @@ impl Analysis {
self.with_db(|db| annotations::resolve_annotation(db, annotation))
}

pub fn move_item(
&self,
range: FileRange,
direction: Direction,
) -> Cancelable<Option<TextEdit>> {
self.with_db(|db| move_item::move_item(db, range, direction))
}

/// Performs an operation on that may be Canceled.
fn with_db<F, T>(&self, f: F) -> Cancelable<T>
where
Expand Down
Loading

0 comments on commit d4fa672

Please sign in to comment.