mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-12-27 05:23:24 +00:00
Merge #4547
4547: Remove unused cursor positions r=matklad a=matklad
bors r+
🤖
Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
This commit is contained in:
commit
a4e6963a23
3 changed files with 3 additions and 8 deletions
|
@ -248,8 +248,7 @@ impl AssistBuilder {
|
||||||
|
|
||||||
fn finish(self, change_label: String) -> SourceChange {
|
fn finish(self, change_label: String) -> SourceChange {
|
||||||
let edit = self.edit.finish();
|
let edit = self.edit.finish();
|
||||||
let mut res = SingleFileChange { label: change_label, edit, cursor_position: None }
|
let mut res = SingleFileChange { label: change_label, edit }.into_source_change(self.file);
|
||||||
.into_source_change(self.file);
|
|
||||||
if self.is_snippet {
|
if self.is_snippet {
|
||||||
res.is_snippet = true;
|
res.is_snippet = true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -82,7 +82,6 @@ fn on_eq_typed(file: &SourceFile, offset: TextSize) -> Option<SingleFileChange>
|
||||||
Some(SingleFileChange {
|
Some(SingleFileChange {
|
||||||
label: "add semicolon".to_string(),
|
label: "add semicolon".to_string(),
|
||||||
edit: TextEdit::insert(offset, ";".to_string()),
|
edit: TextEdit::insert(offset, ";".to_string()),
|
||||||
cursor_position: None,
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -111,7 +110,6 @@ fn on_dot_typed(file: &SourceFile, offset: TextSize) -> Option<SingleFileChange>
|
||||||
Some(SingleFileChange {
|
Some(SingleFileChange {
|
||||||
label: "reindent dot".to_string(),
|
label: "reindent dot".to_string(),
|
||||||
edit: TextEdit::replace(TextRange::new(offset - current_indent_len, offset), target_indent),
|
edit: TextEdit::replace(TextRange::new(offset - current_indent_len, offset), target_indent),
|
||||||
cursor_position: None,
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -130,7 +128,6 @@ fn on_arrow_typed(file: &SourceFile, offset: TextSize) -> Option<SingleFileChang
|
||||||
Some(SingleFileChange {
|
Some(SingleFileChange {
|
||||||
label: "add space after return type".to_string(),
|
label: "add space after return type".to_string(),
|
||||||
edit: TextEdit::insert(after_arrow, " ".to_string()),
|
edit: TextEdit::insert(after_arrow, " ".to_string()),
|
||||||
cursor_position: None,
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
//! It can be viewed as a dual for `AnalysisChange`.
|
//! It can be viewed as a dual for `AnalysisChange`.
|
||||||
|
|
||||||
use ra_db::{FileId, FilePosition, RelativePathBuf, SourceRootId};
|
use ra_db::{FileId, FilePosition, RelativePathBuf, SourceRootId};
|
||||||
use ra_text_edit::{TextEdit, TextSize};
|
use ra_text_edit::TextEdit;
|
||||||
|
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
pub struct SourceChange {
|
pub struct SourceChange {
|
||||||
|
@ -109,7 +109,6 @@ pub enum FileSystemEdit {
|
||||||
pub struct SingleFileChange {
|
pub struct SingleFileChange {
|
||||||
pub label: String,
|
pub label: String,
|
||||||
pub edit: TextEdit,
|
pub edit: TextEdit,
|
||||||
pub cursor_position: Option<TextSize>,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl SingleFileChange {
|
impl SingleFileChange {
|
||||||
|
@ -118,7 +117,7 @@ impl SingleFileChange {
|
||||||
label: self.label,
|
label: self.label,
|
||||||
source_file_edits: vec![SourceFileEdit { file_id, edit: self.edit }],
|
source_file_edits: vec![SourceFileEdit { file_id, edit: self.edit }],
|
||||||
file_system_edits: Vec::new(),
|
file_system_edits: Vec::new(),
|
||||||
cursor_position: self.cursor_position.map(|offset| FilePosition { file_id, offset }),
|
cursor_position: None,
|
||||||
is_snippet: false,
|
is_snippet: false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue