extend selection expands macros and can totally panic
This commit is contained in:
parent
171f6e6d00
commit
73836cdbbc
@ -51,7 +51,7 @@ fn main() {
|
||||
}
|
||||
",
|
||||
);
|
||||
let r = analysis.extend_selection(frange);
|
||||
let r = analysis.extend_selection(frange).unwrap();
|
||||
assert_eq!(r, TextRange::from_to(51.into(), 56.into()));
|
||||
}
|
||||
}
|
||||
|
@ -310,8 +310,8 @@ pub fn file_line_index(&self, file_id: FileId) -> Arc<LineIndex> {
|
||||
}
|
||||
|
||||
/// Selects the next syntactic nodes encopasing the range.
|
||||
pub fn extend_selection(&self, frange: FileRange) -> TextRange {
|
||||
extend_selection::extend_selection(&self.db, frange)
|
||||
pub fn extend_selection(&self, frange: FileRange) -> Cancelable<TextRange> {
|
||||
self.with_db(|db| extend_selection::extend_selection(db, frange))
|
||||
}
|
||||
|
||||
/// Returns position of the mathcing brace (all types of braces are
|
||||
|
@ -8,7 +8,7 @@
|
||||
WorkspaceEdit
|
||||
};
|
||||
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 rustc_hash::FxHashMap;
|
||||
@ -40,9 +40,13 @@ pub fn handle_extend_selection(
|
||||
.into_iter()
|
||||
.map_conv_with(&line_index)
|
||||
.map(|range| FileRange { file_id, range })
|
||||
.map(|frange| world.analysis().extend_selection(frange))
|
||||
.map_conv_with(&line_index)
|
||||
.collect();
|
||||
.map(|frange| {
|
||||
world
|
||||
.analysis()
|
||||
.extend_selection(frange)
|
||||
.map(|it| it.conv_with(&line_index))
|
||||
})
|
||||
.collect::<Cancelable<Vec<_>>>()?;
|
||||
Ok(req::ExtendSelectionResult { selections })
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user