Skip to content

Commit

Permalink
vis: handle further input after mark and register specifiers
Browse files Browse the repository at this point in the history
This fixes martanne#531 in a more robust way. The key handling functions
should be able to handle additional input passed to them as is
for example the case when processing the `gv` mapping.
  • Loading branch information
martanne committed Jul 11, 2017
1 parent 8d2de4b commit 546917d
Showing 1 changed file with 15 additions and 10 deletions.
25 changes: 15 additions & 10 deletions main.c
Original file line number Diff line number Diff line change
Expand Up @@ -1276,8 +1276,9 @@ static const char *macro_record(Vis *vis, const char *keys, const Arg *arg) {
if (!vis_macro_record_stop(vis)) {
if (!keys[0])
return NULL;
if (keys[1])
return vis_keys_next(vis, keys);
const char *next = vis_keys_next(vis, keys);
if (next - keys > 1)
return next;
enum VisRegister reg = vis_register_from(vis, keys[0]);
vis_macro_record(vis, reg);
keys++;
Expand All @@ -1289,8 +1290,9 @@ static const char *macro_record(Vis *vis, const char *keys, const Arg *arg) {
static const char *macro_replay(Vis *vis, const char *keys, const Arg *arg) {
if (!keys[0])
return NULL;
if (keys[1])
return vis_keys_next(vis, keys);
const char *next = vis_keys_next(vis, keys);
if (next - keys > 1)
return next;
enum VisRegister reg = vis_register_from(vis, keys[0]);
vis_macro_replay(vis, reg);
return keys+1;
Expand Down Expand Up @@ -1985,8 +1987,9 @@ static const char *selection_end(Vis *vis, const char *keys, const Arg *arg) {
static const char *reg(Vis *vis, const char *keys, const Arg *arg) {
if (!keys[0])
return NULL;
if (keys[1])
return vis_keys_next(vis, keys);
const char *next = vis_keys_next(vis, keys);
if (next - keys > 1)
return next;
enum VisRegister reg = vis_register_from(vis, keys[0]);
vis_register(vis, reg);
return keys+1;
Expand All @@ -1995,8 +1998,9 @@ static const char *reg(Vis *vis, const char *keys, const Arg *arg) {
static const char *mark(Vis *vis, const char *keys, const Arg *arg) {
if (!keys[0])
return NULL;
if (keys[1])
return vis_keys_next(vis, keys);
const char *next = vis_keys_next(vis, keys);
if (next - keys > 1)
return next;
enum VisMark mark = vis_mark_from(vis, keys[0]);
vis_mark(vis, mark);
return keys+1;
Expand Down Expand Up @@ -2061,8 +2065,9 @@ static const char *delete(Vis *vis, const char *keys, const Arg *arg) {
static const char *insert_register(Vis *vis, const char *keys, const Arg *arg) {
if (!keys[0])
return NULL;
if (keys[1])
return vis_keys_next(vis, keys);
const char *next = vis_keys_next(vis, keys);
if (next - keys > 1)
return next;
enum VisRegister reg = vis_register_from(vis, keys[0]);
if (reg != VIS_REG_INVALID) {
vis_register(vis, reg);
Expand Down

0 comments on commit 546917d

Please sign in to comment.