From ee11eeda3cbebf45b573a236ecdfe62ebcd3859e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Andr=C3=A9=20Tanner?= Date: Wed, 6 Apr 2016 22:34:27 +0200 Subject: sam: avoid taking snapshots within the filter command implementation This has the effect that multiple filter commands can be undone together. --- sam.c | 19 +------------------ 1 file changed, 1 insertion(+), 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) -- cgit v1.2.3