Skip to content

Commit 19ce2d0

Browse files
committed
refactor: simplify BlockNavigation.UpdateByCaretPosition
Signed-off-by: leo <[email protected]>
1 parent c72a151 commit 19ce2d0

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

src/ViewModels/BlockNavigation.cs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -130,23 +130,23 @@ public void UpdateByCaretPosition(int caretLine)
130130
return;
131131
}
132132

133+
_current = -1;
134+
133135
for (var i = 0; i < _blocks.Count; i++)
134136
{
135137
var block = _blocks[i];
136-
if (block.End < caretLine)
137-
continue;
138-
139138
if (block.Start > caretLine)
140-
_current = i - 1;
141-
else
142-
_current = i;
139+
break;
143140

144-
OnPropertyChanged(nameof(Indicator));
145-
break;
141+
_current = i;
142+
if (block.End >= caretLine)
143+
break;
146144
}
145+
146+
OnPropertyChanged(nameof(Indicator));
147147
}
148148

149149
private int _current;
150-
private List<Block> _blocks = [];
150+
private readonly List<Block> _blocks = [];
151151
}
152152
}

0 commit comments

Comments
 (0)