Fix infinite loop in GotoNextInList
This commit is contained in:
@@ -89,14 +89,19 @@ void ToggleConsole() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CheckpointBeforeGoto(WindowID window_id) {
|
void CheckpointBeforeGoto(WindowID window_id, ViewID view_id) {
|
||||||
Window *window = GetWindow(window_id);
|
Window *window = GetWindow(window_id);
|
||||||
View *view = GetView(window->active_view);
|
View *view = GetView(view_id);
|
||||||
Buffer *buffer = GetBuffer(view->active_buffer);
|
Buffer *buffer = GetBuffer(view->active_buffer);
|
||||||
Add(&window->goto_history, {buffer->id, view->carets[0]});
|
Add(&window->goto_history, {buffer->id, view->carets[0]});
|
||||||
window->goto_redo.len = 0;
|
window->goto_redo.len = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CheckpointBeforeGoto(WindowID window_id) {
|
||||||
|
Window *window = GetWindow(window_id);
|
||||||
|
CheckpointBeforeGoto(window_id, window->active_view);
|
||||||
|
}
|
||||||
|
|
||||||
void GotoBackward(WindowID window_id) {
|
void GotoBackward(WindowID window_id) {
|
||||||
Window *window = GetWindow(window_id);
|
Window *window = GetWindow(window_id);
|
||||||
if (window->goto_history.len <= 0) return;
|
if (window->goto_history.len <= 0) return;
|
||||||
|
|||||||
@@ -591,7 +591,6 @@ void Command_Find(View *seek_view, String16 needle, bool forward = true) {
|
|||||||
void Command_GotoNextInList(Window *window, Int line_offset = 1) {
|
void Command_GotoNextInList(Window *window, Int line_offset = 1) {
|
||||||
Assert(line_offset == 1 || line_offset == -1);
|
Assert(line_offset == 1 || line_offset == -1);
|
||||||
ViewID active_view = window->active_view;
|
ViewID active_view = window->active_view;
|
||||||
CheckpointBeforeGoto(window->id);
|
|
||||||
|
|
||||||
View *view_goto = GetView(window->active_goto_list);
|
View *view_goto = GetView(window->active_goto_list);
|
||||||
window->active_view = view_goto->id;
|
window->active_view = view_goto->id;
|
||||||
@@ -601,7 +600,7 @@ void Command_GotoNextInList(Window *window, Int line_offset = 1) {
|
|||||||
Int line = PosToLine(*buffer_goto, pos);
|
Int line = PosToLine(*buffer_goto, pos);
|
||||||
|
|
||||||
bool opened = false;
|
bool opened = false;
|
||||||
for (Int i = line + line_offset; line + line_offset < buffer_goto->line_starts.len && line + line_offset >= 0; i += line_offset) {
|
for (Int i = line + line_offset; i >= 0 && i < buffer_goto->line_starts.len; i += line_offset) {
|
||||||
Range line_range = GetLineRangeWithoutNL(*buffer_goto, line + line_offset);
|
Range line_range = GetLineRangeWithoutNL(*buffer_goto, line + line_offset);
|
||||||
String16 line = GetString(*buffer_goto, line_range);
|
String16 line = GetString(*buffer_goto, line_range);
|
||||||
view_goto->carets[0] = MakeCaret(line_range.min);
|
view_goto->carets[0] = MakeCaret(line_range.min);
|
||||||
@@ -611,6 +610,7 @@ void Command_GotoNextInList(Window *window, Int line_offset = 1) {
|
|||||||
IF_DEBUG(AssertRanges(view_goto->carets));
|
IF_DEBUG(AssertRanges(view_goto->carets));
|
||||||
if (line.len == 0) continue;
|
if (line.len == 0) continue;
|
||||||
|
|
||||||
|
CheckpointBeforeGoto(window->id, active_view);
|
||||||
Open(line);
|
Open(line);
|
||||||
opened = true;
|
opened = true;
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
- Remove pointers and use ViewIDs (enable array debug while doing this)
|
- Remove pointers and use ViewIDs (enable array debug while doing this)
|
||||||
- Remove console and command window, provide alternatives but unify the interface?
|
- Remove console and command window, provide alternatives but unify the interface?
|
||||||
|
|
||||||
- Ctrl + . to chop a path from buffer name and open that
|
|
||||||
- apply clang format
|
- apply clang format
|
||||||
- apply clang format on save
|
- apply clang format on save
|
||||||
- OnWindowCommand allow config user to overwrite the WindowCommand keybinding, introduce his own
|
- OnWindowCommand allow config user to overwrite the WindowCommand keybinding, introduce his own
|
||||||
|
|||||||
Reference in New Issue
Block a user