Improving the jump history

This commit is contained in:
Krzosa Karol
2026-01-05 10:30:17 +01:00
parent 77c6bf3da9
commit 80ea09b3ea
6 changed files with 24 additions and 13 deletions

View File

@@ -7,10 +7,9 @@
- Remedybg commands integrated! (like clicking f5 and opening up the window) - Remedybg commands integrated! (like clicking f5 and opening up the window)
- Variable documentation ????? not looking too good due to formatting - Variable documentation ????? not looking too good due to formatting
- OnUpdate view hooks! - OnUpdate view hooks!
- JumpHistory maybe a smarter algorithm is needed, like accept only if line also changed
- Macros - Macros
- ctrl-shift-f should insert the selected into search - ctrl-shift-f should insert the selected into search
- jump history batching doesn't work ... - ctrl-e started doing no-ops again ...
Use session 4 Use session 4
- ListVariables instead of GenerateConfig, auto saving of variables - ListVariables instead of GenerateConfig, auto saving of variables

View File

@@ -952,7 +952,7 @@ API void RedoEdit(Buffer *buffer, Array<Caret> *carets) {
if (buffer->redo_stack.len > 0) { if (buffer->redo_stack.len > 0) {
HistoryEntry *next = GetLast(buffer->redo_stack); HistoryEntry *next = GetLast(buffer->redo_stack);
if (next->time - entry.time <= UndoMergeTime) { if ((next->time - entry.time) <= UndoMergeTime) {
RedoEdit(buffer, carets); RedoEdit(buffer, carets);
} }
} }
@@ -978,7 +978,7 @@ API void UndoEdit(Buffer *buffer, Array<Caret> *carets) {
if (buffer->undo_stack.len > 0) { if (buffer->undo_stack.len > 0) {
HistoryEntry *next = GetLast(buffer->undo_stack); HistoryEntry *next = GetLast(buffer->undo_stack);
if (entry.time - next->time <= UndoMergeTime) { if ((entry.time - next->time) <= UndoMergeTime) {
UndoEdit(buffer, carets); UndoEdit(buffer, carets);
} }
} }

View File

@@ -856,7 +856,7 @@ void CMD_SetWorkDirHere() {
} RegisterCommand(CMD_SetWorkDirHere, "", "Sets work directory to the directory of the current buffer, it also renames couple special buffers to make them accomodate the new WorkDir"); } RegisterCommand(CMD_SetWorkDirHere, "", "Sets work directory to the directory of the current buffer, it also renames couple special buffers to make them accomodate the new WorkDir");
void Coro_OpenCode(mco_coro *co) { void Coro_OpenCode(mco_coro *co) {
Array<String> patterns = Split(CoCurr->arena, NonCodePatterns_EndsWith, "|"); Array<String> patterns = Split(CoCurr->arena, OpenCodeCommandExcludePatterns, "|");
Array<String> dirs = {CoCurr->arena}; Array<String> dirs = {CoCurr->arena};
String *param_dir = (String *)CoCurr->user_ctx; String *param_dir = (String *)CoCurr->user_ctx;
Add(&dirs, *param_dir); Add(&dirs, *param_dir);

View File

@@ -163,7 +163,7 @@ RegisterVariable(String, WindowsVCVarsPathToLoadDevEnviroment, "C:/Program Files
RegisterVariable(Float, UndoMergeTime, 0.3); RegisterVariable(Float, UndoMergeTime, 0.3);
RegisterVariable(Float, JumpHistoryMergeTime, 0.3); RegisterVariable(Float, JumpHistoryMergeTime, 0.3);
RegisterVariable(String, InternetBrowser, "firefox"); RegisterVariable(String, InternetBrowser, "firefox");
RegisterVariable(String, NonCodePatterns_EndsWith, ".git/|.obj|.o|.pdb|.exe|.ilk|.ttf|.ico|.gif|.jpg|.png|.spall|.dll|.so|.a|.lib"); RegisterVariable(String, OpenCodeCommandExcludePatterns, ".git/|.obj|.o|.pdb|.exe|.ilk|.ttf|.ico|.gif|.jpg|.png|.spall|.dll|.so|.a|.lib");
RegisterVariable(Int, TrimTrailingWhitespace, 1); RegisterVariable(Int, TrimTrailingWhitespace, 1);
RegisterVariable(Int, FormatCode, 0); RegisterVariable(Int, FormatCode, 0);
RegisterVariable(Int, SetModifiesConfig, 1); RegisterVariable(Int, SetModifiesConfig, 1);

View File

@@ -613,12 +613,24 @@ void Update(Event event) {
For (Windows) { For (Windows) {
if (it->jump_history) { if (it->jump_history) {
View *view = GetView(it->active_view); 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); bool should_checkpoint = true;
if (!are_equal) { if (it->skip_checkpoint) {
if (!it->skip_checkpoint) { should_checkpoint = false;
Add(&it->goto_history, it->begin_frame_crumb); }
it->goto_redo.len = 0; if (should_checkpoint && it->begin_frame_crumb.view_id == it->active_view) {
if (AreEqual(view->carets[0], it->begin_frame_crumb.caret)) {
should_checkpoint = false;
} }
Buffer *buffer = GetBuffer(view->active_buffer);
if (PosToLine(buffer, GetFront(view->main_caret_on_begin_frame)) == PosToLine(buffer, GetFront(view->carets[0]))) {
should_checkpoint = false;
}
}
if (should_checkpoint) {
Add(&it->goto_history, it->begin_frame_crumb);
it->goto_redo.len = 0;
} }
it->skip_checkpoint = false; it->skip_checkpoint = false;
} }

View File

@@ -278,7 +278,7 @@ void JumpBack(Window *window) {
if (window->goto_history.len) { if (window->goto_history.len) {
GotoCrumb *next = GetLast(window->goto_history); GotoCrumb *next = GetLast(window->goto_history);
if (c.view_id == next->view_id && c.time - next->time <= JumpHistoryMergeTime) { if (c.view_id == next->view_id && ((c.time - next->time) <= JumpHistoryMergeTime)) {
JumpBack(window); JumpBack(window);
} }
} }
@@ -298,7 +298,7 @@ void JumpForward(Window *window) {
if (window->goto_redo.len) { if (window->goto_redo.len) {
GotoCrumb *next = GetLast(window->goto_redo); GotoCrumb *next = GetLast(window->goto_redo);
if (c.view_id == next->view_id && next->time - c.time <= JumpHistoryMergeTime) { if ((c.view_id == next->view_id) && ((next->time - c.time) <= JumpHistoryMergeTime)) {
JumpForward(window); JumpForward(window);
} }
} }