aboutsummaryrefslogtreecommitdiff
path: root/vis.c
diff options
context:
space:
mode:
Diffstat (limited to 'vis.c')
-rw-r--r--vis.c26
1 files changed, 10 insertions, 16 deletions
diff --git a/vis.c b/vis.c
index 489957a..1138dd7 100644
--- a/vis.c
+++ b/vis.c
@@ -670,25 +670,19 @@ static const char *vis_keys_raw(Vis *vis, Buffer *buf, const char *input) {
prefix = false;
binding = NULL;
- Mode *mode = vis->mode;
- for (size_t i = 0; i < LENGTH(vis->win->modes); i++) {
- if (mode == &vis_modes[i]) {
- if (vis->win->modes[i].bindings)
- mode = &vis->win->modes[i];
- break;
+ for (Mode *mode = vis->mode; mode && !binding && !prefix; mode = mode->parent) {
+ for (int global = 0; global < 2 && !binding && !prefix; global++) {
+ Mode *mode_local = global ? mode : &vis->win->modes[mode->id];
+ if (!mode_local->bindings)
+ continue;
+ binding = map_get(mode_local->bindings, start);
+ /* "<" is never treated as a prefix because it is used to denote
+ * special key symbols */
+ if (strcmp(cur, "<"))
+ prefix = !binding && map_contains(mode_local->bindings, start);
}
}
- for (; mode && !binding && !prefix; mode = mode->parent) {
- if (!mode->bindings)
- continue;
- binding = map_get(mode->bindings, start);
- /* "<" is never treated as a prefix because it is used to denote
- * special key symbols */
- if (strcmp(cur, "<"))
- prefix = !binding && map_contains(mode->bindings, start);
- }
-
*end = tmp;
vis->keys = buf;