Skip to content

Commit e8e6756

Browse files
paulwkckoutcher
authored andcommitted
Update display after setting column option (#1384)
This resolves issue that display is not updated after updating column option value like :set main-view-date-use-author = yes [tk: refactoring and fixed only view column options are prefixed]
1 parent 1295174 commit e8e6756

File tree

1 file changed

+39
-17
lines changed

1 file changed

+39
-17
lines changed

src/prompt.c

Lines changed: 39 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -891,6 +891,36 @@ prompt_toggle(struct view *view, const char *argv[], enum view_flag *flags)
891891
return error("`:toggle %s` not supported", option);
892892
}
893893

894+
static enum view_flag
895+
prompt_option_flags(struct view *view, const char *option)
896+
{
897+
struct option_info template;
898+
struct option_info *toggle;
899+
struct view_column *column;
900+
const char *column_name;
901+
902+
toggle = find_option_info(option_toggles, ARRAY_SIZE(option_toggles), "", option);
903+
904+
if (!toggle || !toggle->flags) {
905+
const char *prefixed;
906+
907+
if ((prefixed = strstr(option, "-view-"))) {
908+
option = prefixed + STRING_SIZE("-view-");
909+
for (column = view->columns; column; column = column->next) {
910+
toggle = find_column_option_info(column->type, &column->opt,
911+
option, &template, &column_name);
912+
if (toggle)
913+
return toggle->flags;
914+
}
915+
}
916+
}
917+
918+
if (toggle)
919+
return toggle->flags;
920+
921+
return VIEW_NO_FLAGS;
922+
}
923+
894924
static void
895925
prompt_update_display(enum view_flag flags)
896926
{
@@ -1059,7 +1089,6 @@ run_prompt_command(struct view *view, const char *argv[])
10591089
} else {
10601090
struct key key = {{0}};
10611091
enum status_code code;
1062-
enum view_flag flags = VIEW_NO_FLAGS;
10631092

10641093
/* Try :<key> */
10651094
key.modifiers.multibytes = 1;
@@ -1080,25 +1109,18 @@ run_prompt_command(struct view *view, const char *argv[])
10801109
}
10811110

10821111
if (!strcmp(cmd, "set")) {
1083-
struct option_info *toggle;
1084-
1085-
toggle = find_option_info(option_toggles, ARRAY_SIZE(option_toggles),
1086-
"", argv[1]);
1087-
1088-
if (toggle)
1089-
flags = toggle->flags;
1090-
}
1091-
1092-
if (flags) {
1093-
prompt_update_display(flags);
1112+
enum view_flag flags = prompt_option_flags(view, argv[1]);
10941113

1095-
} else {
1096-
if (!strcmp(cmd, "color"))
1097-
init_colors();
1098-
resize_display();
1099-
redraw_display(true);
1114+
if (flags) {
1115+
prompt_update_display(flags);
1116+
return REQ_NONE;
1117+
}
11001118
}
11011119

1120+
if (!strcmp(cmd, "color"))
1121+
init_colors();
1122+
resize_display();
1123+
redraw_display(true);
11021124
}
11031125
return REQ_NONE;
11041126
}

0 commit comments

Comments
 (0)