mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-27 20:42:04 +00:00
extend selection expands macros and can totally panic
This commit is contained in:
parent
171f6e6d00
commit
73836cdbbc
3 changed files with 11 additions and 7 deletions
|
@ -51,7 +51,7 @@ mod tests {
|
||||||
}
|
}
|
||||||
",
|
",
|
||||||
);
|
);
|
||||||
let r = analysis.extend_selection(frange);
|
let r = analysis.extend_selection(frange).unwrap();
|
||||||
assert_eq!(r, TextRange::from_to(51.into(), 56.into()));
|
assert_eq!(r, TextRange::from_to(51.into(), 56.into()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -310,8 +310,8 @@ impl Analysis {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Selects the next syntactic nodes encopasing the range.
|
/// Selects the next syntactic nodes encopasing the range.
|
||||||
pub fn extend_selection(&self, frange: FileRange) -> TextRange {
|
pub fn extend_selection(&self, frange: FileRange) -> Cancelable<TextRange> {
|
||||||
extend_selection::extend_selection(&self.db, frange)
|
self.with_db(|db| extend_selection::extend_selection(db, frange))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns position of the mathcing brace (all types of braces are
|
/// Returns position of the mathcing brace (all types of braces are
|
||||||
|
|
|
@ -8,7 +8,7 @@ use lsp_types::{
|
||||||
WorkspaceEdit
|
WorkspaceEdit
|
||||||
};
|
};
|
||||||
use ra_ide_api::{
|
use ra_ide_api::{
|
||||||
FileId, FilePosition, FileRange, FoldKind, Query, RangeInfo, RunnableKind, Severity,
|
FileId, FilePosition, FileRange, FoldKind, Query, RangeInfo, RunnableKind, Severity, Cancelable,
|
||||||
};
|
};
|
||||||
use ra_syntax::{AstNode, TextUnit};
|
use ra_syntax::{AstNode, TextUnit};
|
||||||
use rustc_hash::FxHashMap;
|
use rustc_hash::FxHashMap;
|
||||||
|
@ -40,9 +40,13 @@ pub fn handle_extend_selection(
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.map_conv_with(&line_index)
|
.map_conv_with(&line_index)
|
||||||
.map(|range| FileRange { file_id, range })
|
.map(|range| FileRange { file_id, range })
|
||||||
.map(|frange| world.analysis().extend_selection(frange))
|
.map(|frange| {
|
||||||
.map_conv_with(&line_index)
|
world
|
||||||
.collect();
|
.analysis()
|
||||||
|
.extend_selection(frange)
|
||||||
|
.map(|it| it.conv_with(&line_index))
|
||||||
|
})
|
||||||
|
.collect::<Cancelable<Vec<_>>>()?;
|
||||||
Ok(req::ExtendSelectionResult { selections })
|
Ok(req::ExtendSelectionResult { selections })
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue