aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarc André Tanner <mat@brain-dump.org>2014-09-05 07:47:54 +0200
committerMarc André Tanner <mat@brain-dump.org>2014-09-05 07:47:54 +0200
commit155fc47c9e3aab3e09616c68f44d9fc49e57c6ee (patch)
treeff32963c04e8db73e04959faefe9b6717eb10469
parentabcb867f74efd37ec66490c201204c668920b2ab (diff)
downloadvis-155fc47c9e3aab3e09616c68f44d9fc49e57c6ee.tar.gz
vis-155fc47c9e3aab3e09616c68f44d9fc49e57c6ee.tar.xz
In visual mode operators should operate on the selected text
-rw-r--r--config.def.h16
1 files changed, 14 insertions, 2 deletions
diff --git a/config.def.h b/config.def.h
index fe585fa..ae1c986 100644
--- a/config.def.h
+++ b/config.def.h
@@ -259,8 +259,14 @@ static void linewise(const Arg *arg) {
}
static void operator(const Arg *arg) {
- switchmode(&(const Arg){ .i = VIS_MODE_OPERATOR });
Operator *op = &ops[arg->i];
+ if (mode == &vis_modes[VIS_MODE_VISUAL]) {
+ action.op = op;
+ action_do(&action);
+ return;
+ }
+
+ switchmode(&(const Arg){ .i = VIS_MODE_OPERATOR });
if (action.op == op) {
/* hacky way to handle double operators i.e. things like
* dd, yy etc where the second char isn't a movement */
@@ -380,7 +386,7 @@ void action_do(Action *a) {
r = a->textobj->range(txt, pos);
// TODO range_valid?
if (r.start == (size_t)-1 || r.end == (size_t)-1)
- continue;
+ break;
if (a->textobj->type == OUTER) {
r.start--;
r.end++;
@@ -396,12 +402,18 @@ void action_do(Action *a) {
}
}
}
+ } else if (mode == &vis_modes[VIS_MODE_VISUAL]) {
+ c.range = window_selection_get(win);
+ if (c.range.start == (size_t)-1 || c.range.end == (size_t)-1)
+ c.range.start = c.range.end = pos;
}
if (a->op) {
a->op->func(&c);
if (mode == &vis_modes[VIS_MODE_OPERATOR])
switchmode_to(mode_prev);
+ else if (mode == &vis_modes[VIS_MODE_VISUAL])
+ switchmode(&(const Arg){ .i = VIS_MODE_NORMAL });
}
if (a != &action_prev) {