diff options
Diffstat (limited to 'crates')
-rw-r--r-- | crates/ra_assists/src/assist_context.rs | 3 | ||||
-rw-r--r-- | crates/ra_assists/src/handlers/early_return.rs | 2 | ||||
-rw-r--r-- | crates/ra_assists/src/handlers/merge_imports.rs | 2 | ||||
-rw-r--r-- | crates/ra_assists/src/handlers/merge_match_arms.rs | 2 | ||||
-rw-r--r-- | crates/ra_assists/src/handlers/split_import.rs | 2 |
5 files changed, 5 insertions, 6 deletions
diff --git a/crates/ra_assists/src/assist_context.rs b/crates/ra_assists/src/assist_context.rs index 81052ab49..3085c4330 100644 --- a/crates/ra_assists/src/assist_context.rs +++ b/crates/ra_assists/src/assist_context.rs | |||
@@ -76,8 +76,7 @@ impl<'a> AssistContext<'a> { | |||
76 | find_node_at_offset(self.source_file.syntax(), self.offset()) | 76 | find_node_at_offset(self.source_file.syntax(), self.offset()) |
77 | } | 77 | } |
78 | pub(crate) fn find_node_at_offset_with_descend<N: AstNode>(&self) -> Option<N> { | 78 | pub(crate) fn find_node_at_offset_with_descend<N: AstNode>(&self) -> Option<N> { |
79 | self.sema | 79 | self.sema.find_node_at_offset_with_descend(self.source_file.syntax(), self.offset()) |
80 | .find_node_at_offset_with_descend(self.source_file.syntax(), self.frange.range.start()) | ||
81 | } | 80 | } |
82 | pub(crate) fn covering_element(&self) -> SyntaxElement { | 81 | pub(crate) fn covering_element(&self) -> SyntaxElement { |
83 | find_covering_element(self.source_file.syntax(), self.frange.range) | 82 | find_covering_element(self.source_file.syntax(), self.frange.range) |
diff --git a/crates/ra_assists/src/handlers/early_return.rs b/crates/ra_assists/src/handlers/early_return.rs index ccf91797c..810784ad5 100644 --- a/crates/ra_assists/src/handlers/early_return.rs +++ b/crates/ra_assists/src/handlers/early_return.rs | |||
@@ -93,7 +93,7 @@ pub(crate) fn convert_to_guarded_return(acc: &mut Assists, ctx: &AssistContext) | |||
93 | } | 93 | } |
94 | 94 | ||
95 | then_block.syntax().last_child_or_token().filter(|t| t.kind() == R_CURLY)?; | 95 | then_block.syntax().last_child_or_token().filter(|t| t.kind() == R_CURLY)?; |
96 | let cursor_position = ctx.frange.range.start(); | 96 | let cursor_position = ctx.offset(); |
97 | 97 | ||
98 | let target = if_expr.syntax().text_range(); | 98 | let target = if_expr.syntax().text_range(); |
99 | acc.add(AssistId("convert_to_guarded_return"), "Convert to guarded return", target, |edit| { | 99 | acc.add(AssistId("convert_to_guarded_return"), "Convert to guarded return", target, |edit| { |
diff --git a/crates/ra_assists/src/handlers/merge_imports.rs b/crates/ra_assists/src/handlers/merge_imports.rs index 8e1d93312..ac3e53c27 100644 --- a/crates/ra_assists/src/handlers/merge_imports.rs +++ b/crates/ra_assists/src/handlers/merge_imports.rs | |||
@@ -26,7 +26,7 @@ use crate::{ | |||
26 | pub(crate) fn merge_imports(acc: &mut Assists, ctx: &AssistContext) -> Option<()> { | 26 | pub(crate) fn merge_imports(acc: &mut Assists, ctx: &AssistContext) -> Option<()> { |
27 | let tree: ast::UseTree = ctx.find_node_at_offset()?; | 27 | let tree: ast::UseTree = ctx.find_node_at_offset()?; |
28 | let mut rewriter = SyntaxRewriter::default(); | 28 | let mut rewriter = SyntaxRewriter::default(); |
29 | let mut offset = ctx.frange.range.start(); | 29 | let mut offset = ctx.offset(); |
30 | 30 | ||
31 | if let Some(use_item) = tree.syntax().parent().and_then(ast::UseItem::cast) { | 31 | if let Some(use_item) = tree.syntax().parent().and_then(ast::UseItem::cast) { |
32 | let (merged, to_delete) = next_prev() | 32 | let (merged, to_delete) = next_prev() |
diff --git a/crates/ra_assists/src/handlers/merge_match_arms.rs b/crates/ra_assists/src/handlers/merge_match_arms.rs index cfe4df47b..d4e38aa6a 100644 --- a/crates/ra_assists/src/handlers/merge_match_arms.rs +++ b/crates/ra_assists/src/handlers/merge_match_arms.rs | |||
@@ -45,7 +45,7 @@ pub(crate) fn merge_match_arms(acc: &mut Assists, ctx: &AssistContext) -> Option | |||
45 | InExpr(TextSize), | 45 | InExpr(TextSize), |
46 | InPat(TextSize), | 46 | InPat(TextSize), |
47 | } | 47 | } |
48 | let cursor_pos = ctx.frange.range.start(); | 48 | let cursor_pos = ctx.offset(); |
49 | let cursor_pos = if current_expr.syntax().text_range().contains(cursor_pos) { | 49 | let cursor_pos = if current_expr.syntax().text_range().contains(cursor_pos) { |
50 | CursorPos::InExpr(current_text_range.end() - cursor_pos) | 50 | CursorPos::InExpr(current_text_range.end() - cursor_pos) |
51 | } else { | 51 | } else { |
diff --git a/crates/ra_assists/src/handlers/split_import.rs b/crates/ra_assists/src/handlers/split_import.rs index 159033731..b2757e50c 100644 --- a/crates/ra_assists/src/handlers/split_import.rs +++ b/crates/ra_assists/src/handlers/split_import.rs | |||
@@ -26,7 +26,7 @@ pub(crate) fn split_import(acc: &mut Assists, ctx: &AssistContext) -> Option<()> | |||
26 | if new_tree == use_tree { | 26 | if new_tree == use_tree { |
27 | return None; | 27 | return None; |
28 | } | 28 | } |
29 | let cursor = ctx.frange.range.start(); | 29 | let cursor = ctx.offset(); |
30 | 30 | ||
31 | let target = colon_colon.text_range(); | 31 | let target = colon_colon.text_range(); |
32 | acc.add(AssistId("split_import"), "Split import", target, |edit| { | 32 | acc.add(AssistId("split_import"), "Split import", target, |edit| { |