mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-30 22:01:37 +00:00
hide atom edits a bit
This commit is contained in:
parent
164d53b22f
commit
0063f03e86
5 changed files with 24 additions and 12 deletions
|
@ -97,21 +97,21 @@ impl ConvWith for TextEdit {
|
|||
type Output = Vec<languageserver_types::TextEdit>;
|
||||
|
||||
fn conv_with(self, line_index: &LineIndex) -> Vec<languageserver_types::TextEdit> {
|
||||
self.into_atoms()
|
||||
self.as_atoms()
|
||||
.into_iter()
|
||||
.map_conv_with(line_index)
|
||||
.collect()
|
||||
}
|
||||
}
|
||||
|
||||
impl ConvWith for AtomTextEdit {
|
||||
impl<'a> ConvWith for &'a AtomTextEdit {
|
||||
type Ctx = LineIndex;
|
||||
type Output = languageserver_types::TextEdit;
|
||||
|
||||
fn conv_with(self, line_index: &LineIndex) -> languageserver_types::TextEdit {
|
||||
languageserver_types::TextEdit {
|
||||
range: self.delete.conv_with(line_index),
|
||||
new_text: self.insert,
|
||||
new_text: self.insert.clone(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -199,7 +199,7 @@ impl TryConvWith for SourceChange {
|
|||
.source_file_edits
|
||||
.iter()
|
||||
.find(|it| it.file_id == pos.file_id)
|
||||
.map(|it| it.edits.as_slice())
|
||||
.map(|it| it.edit.as_atoms())
|
||||
.unwrap_or(&[]);
|
||||
let line_col = translate_offset_with_edit(&*line_index, pos.offset, edits);
|
||||
let position =
|
||||
|
@ -265,7 +265,12 @@ impl TryConvWith for SourceFileEdit {
|
|||
version: None,
|
||||
};
|
||||
let line_index = world.analysis().file_line_index(self.file_id);
|
||||
let edits = self.edits.into_iter().map_conv_with(&line_index).collect();
|
||||
let edits = self
|
||||
.edit
|
||||
.as_atoms()
|
||||
.iter()
|
||||
.map_conv_with(&line_index)
|
||||
.collect();
|
||||
Ok(TextDocumentEdit {
|
||||
text_document,
|
||||
edits,
|
||||
|
|
|
@ -107,9 +107,16 @@ pub fn handle_on_type_formatting(
|
|||
};
|
||||
let edits = match world.analysis().on_eq_typed(position) {
|
||||
None => return Ok(None),
|
||||
Some(mut action) => action.source_file_edits.pop().unwrap().edits,
|
||||
Some(mut action) => action
|
||||
.source_file_edits
|
||||
.pop()
|
||||
.unwrap()
|
||||
.edit
|
||||
.as_atoms()
|
||||
.iter()
|
||||
.map_conv_with(&line_index)
|
||||
.collect(),
|
||||
};
|
||||
let edits = edits.into_iter().map_conv_with(&line_index).collect();
|
||||
Ok(Some(edits))
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue