Skip to content

Commit c5e5bd8

Browse files
committed
acquire parent directly via Some()
1 parent 1451434 commit c5e5bd8

1 file changed

Lines changed: 4 additions & 5 deletions

File tree

crates/syntax/src/syntax_editor/edit_algo.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -217,9 +217,9 @@ pub(super) fn apply_edits(editor: SyntaxEditor) -> SyntaxEdit {
217217
}
218218
Change::Insert(_, SyntaxElement::Token(token))
219219
| Change::Replace(_, Some(SyntaxElement::Token(token))) => {
220-
if token.parent().is_some() {
220+
if let Some(parent) = token.parent() {
221221
let idx = token.index();
222-
let new_parent = token.parent().unwrap().clone_subtree().clone_for_update();
222+
let new_parent = parent.clone_subtree().clone_for_update();
223223
*token = new_parent
224224
.children_with_tokens()
225225
.nth(idx)
@@ -240,10 +240,9 @@ pub(super) fn apply_edits(editor: SyntaxEditor) -> SyntaxEdit {
240240
}
241241
}
242242
SyntaxElement::Token(token) => {
243-
if token.parent().is_some() {
243+
if let Some(parent) = token.parent() {
244244
let idx = token.index();
245-
let new_parent =
246-
token.parent().unwrap().clone_subtree().clone_for_update();
245+
let new_parent = parent.clone_subtree().clone_for_update();
247246
*token = new_parent
248247
.children_with_tokens()
249248
.nth(idx)

0 commit comments

Comments
 (0)