mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-30 13:51:31 +00:00
flip syntax text to use internal iteration
This commit is contained in:
parent
8f032d6a58
commit
8467ba8cdb
4 changed files with 78 additions and 38 deletions
|
@ -83,12 +83,12 @@ fn structure_node(node: &SyntaxNode) -> Option<StructureNode> {
|
|||
|
||||
fn collapse_ws(node: &SyntaxNode, output: &mut String) {
|
||||
let mut can_insert_ws = false;
|
||||
for chunk in node.text().chunks() {
|
||||
node.text().for_each_chunk(|chunk| {
|
||||
for line in chunk.lines() {
|
||||
let line = line.trim();
|
||||
if line.is_empty() {
|
||||
if can_insert_ws {
|
||||
output.push_str(" ");
|
||||
output.push(' ');
|
||||
can_insert_ws = false;
|
||||
}
|
||||
} else {
|
||||
|
@ -96,7 +96,7 @@ fn structure_node(node: &SyntaxNode) -> Option<StructureNode> {
|
|||
can_insert_ws = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
visitor()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue