diff --git a/NEWS.adoc b/NEWS.adoc index d62dae2bf..a046db1ac 100644 --- a/NEWS.adoc +++ b/NEWS.adoc @@ -7,6 +7,7 @@ master Improvements: - Open the blob corresponding to the diff line. (#1334) + - Keep cursor position when toggling file-filter in the main view. tig-2.5.10 ---------- diff --git a/src/main.c b/src/main.c index 912505706..fadd656c9 100644 --- a/src/main.c +++ b/src/main.c @@ -100,9 +100,13 @@ main_add_commit(struct view *view, enum line_type type, struct commit *template, view_column_info_update(view, line); - if ((opt_start_on_head && is_head_commit(commit->id)) || - (view->env->goto_id[0] && !strncmp(view->env->goto_id, commit->id, SIZEOF_REV - 1))) + if (view->env->goto_id[0] && !strncmp(view->env->goto_id, commit->id, SIZEOF_REV - 1)) { select_view_line(view, line->lineno + 1); + view->env->goto_id[0] = 0; + } else if (opt_start_on_head && is_head_commit(commit->id)) { + select_view_line(view, line->lineno + 1); + opt_start_on_head = false; + } return commit; } diff --git a/src/prompt.c b/src/prompt.c index 4f307388f..7463d46cb 100644 --- a/src/prompt.c +++ b/src/prompt.c @@ -460,7 +460,7 @@ readline_init(void) /* Allow conditional parsing of the ~/.inputrc file. */ rl_readline_name = "tig"; - /* Word break caracters (we removed '(' to match variables) */ + /* Word break characters (we removed '(' to match variables) */ rl_basic_word_break_characters = " \t\n\"\\'`@$><=;|&{"; /* Custom display function */ @@ -872,8 +872,13 @@ prompt_toggle(struct view *view, const char *argv[], enum view_flag *flags) } toggle = find_option_info(option_toggles, ARRAY_SIZE(option_toggles), "", option); - if (toggle) + if (toggle) { + if (!strcmp(toggle->name, "file_filter") && + view_has_flags(view, VIEW_FILE_FILTER) && + view_has_flags(view, VIEW_LOG_LIKE)) + string_copy_rev(view->env->goto_id, view->env->commit); return prompt_toggle_option(view, argv, "", toggle, flags); + } for (column = view->columns; column; column = column->next) { toggle = find_column_option_info(column->type, &column->opt, option, &template, &column_name);