Checkpoint automation

This commit is contained in:
Krzosa Karol
2025-12-26 20:59:52 +01:00
parent 44bf7c68ff
commit 29ad3a8f08
9 changed files with 46 additions and 37 deletions

View File

@@ -170,9 +170,14 @@ void OnCommand(Event event) {
//
// Window cursor setting
//
Scratch scratch;
Scratch scratch;
Array<Window *> order = GetWindowZOrder(scratch);
Window *window = GetWindow(ActiveWindowID);
{
}
// Handle wheel scrolling
if (event.xwheel || event.ywheel) {
@@ -330,8 +335,6 @@ void OnCommand(Event event) {
bool mouse_in_line_numbers = AreOverlapping(mouse, active.window->line_numbers_rect);
if (mouse_in_document || mouse_in_line_numbers) {
DocumentSelected = active.window->id;
CheckpointBeforeGoto(active.window);
Int p = ScreenSpaceToBufferPos(active.window, active.view, active.buffer, mouse);
if (Alt()) Insert(&active.view->carets, MakeCaret(p, p), 0);
@@ -502,7 +505,7 @@ void Update(Event event) {
ProfileFunction();
LayoutWindows(event.xwindow, event.ywindow);
Scratch scratch;
Scratch scratch;
Array<Window *> order = GetWindowZOrder(scratch);
For(order) {
if (!it->visible) {
@@ -513,6 +516,12 @@ void Update(Event event) {
view->update_scroll = true;
}
For (Windows) {
if (it->jump_history) {
View *view = GetView(it->active_view);
it->begin_frame_crumb = {it->active_view, view->carets[0], GetTimeSeconds()};
}
}
OnCommand(event);
StatusWindowUpdate();
@@ -521,17 +530,37 @@ void Update(Event event) {
SearchWindowUpdate();
UpdateProcesses();
CoUpdate(&event);
For (Buffers) it->begin_frame_change_id = it->change_id; // after last place we modify
// We update it here despite the name to make it sure that all the possible changes are
// included albeit with delayed response. If we did this at the beginning of the frame
// and the DebugWindowUpdated we wouldnt get to know that in the OnCommand.
For (Buffers) {
it->begin_frame_change_id = it->change_id;
}
{
ProfileScope(WindowEndOfFrameVisibilityAndLastActive);
For (Windows) {
if (it->goto_history.len > ConfigJumpHistorySize) {
RemoveByIndex(&it->goto_history, 0);
}
if (it->goto_redo.len > ConfigJumpHistorySize) {
RemoveByIndex(&it->goto_redo, 0);
if (it->jump_history) {
View *view = GetView(it->active_view);
bool are_equal = it->begin_frame_crumb.view_id == it->active_view && AreEqual(view->carets[0], it->begin_frame_crumb.caret);
if (!are_equal) {
if (!it->skip_checkpoint) {
Add(&it->goto_history, it->begin_frame_crumb);
it->goto_redo.len = 0;
}
}
it->skip_checkpoint = false;
if (it->goto_history.len > ConfigJumpHistorySize) {
RemoveByIndex(&it->goto_history, 0);
}
if (it->goto_redo.len > ConfigJumpHistorySize) {
RemoveByIndex(&it->goto_redo, 0);
}
}
if (it->sync_visibility_with_focus) {
if (it->id == ActiveWindowID) {
it->visible = true;