aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarc André Tanner <mat@brain-dump.org>2016-04-06 22:34:27 +0200
committerMarc André Tanner <mat@brain-dump.org>2016-05-05 11:19:47 +0200
commitee11eeda3cbebf45b573a236ecdfe62ebcd3859e (patch)
tree535b272d521c6f29013b54ee0fc1de0c3aa5f86b
parent54b734939eea44ae84578daaa8e67f8110da7e4f (diff)
downloadvis-ee11eeda3cbebf45b573a236ecdfe62ebcd3859e.tar.gz
vis-ee11eeda3cbebf45b573a236ecdfe62ebcd3859e.tar.xz
sam: avoid taking snapshots within the filter command implementation
This has the effect that multiple filter commands can be undone together.
-rw-r--r--sam.c19
1 files changed, 1 insertions, 18 deletions
diff --git a/sam.c b/sam.c
index 1f452d6..3db08fd 100644
--- a/sam.c
+++ b/sam.c
@@ -1141,20 +1141,6 @@ static bool cmd_filter(Vis *vis, Win *win, Command *cmd, const char *argv[], Cur
return false;
Text *txt = win->file->text;
- /* The general idea is the following:
- *
- * 1) take a snapshot
- * 2) write [range.start, range.end] to external command
- * 3) read the output of the external command and insert it after the range
- * 4) depending on the exit status of the external command
- * - on success: delete original range
- * - on failure: revert to previous snapshot
- *
- * 2) and 3) happen in small chunks
- */
-
- text_snapshot(txt);
-
Filter filter = {
.vis = vis,
.txt = txt,
@@ -1168,14 +1154,11 @@ static bool cmd_filter(Vis *vis, Win *win, Command *cmd, const char *argv[], Cur
if (status == 0) {
text_delete_range(txt, range);
- text_snapshot(txt);
range->end = filter.pos - text_range_size(range);
if (cur)
view_cursors_to(cur, range->start);
} else {
- /* make sure we have somehting to undo */
- text_insert(txt, filter.pos, " ", 1);
- text_undo(txt);
+ text_delete(txt, range->end, filter.pos - range->end);
}
if (vis->cancel_filter)