From 98822c99dcbbcf5e80206ac29775bd8ed34aaacf Mon Sep 17 00:00:00 2001 From: "Michael D. Lowis" Date: Thu, 22 Dec 2016 09:07:34 -0500 Subject: [PATCH] Escape now clears the selection if one already exists. Otherwise it will select the previously inserted text --- TODO.md | 1 + libedit/view.c | 12 ++++++++---- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/TODO.md b/TODO.md index 5fa8434..7a7c9a7 100644 --- a/TODO.md +++ b/TODO.md @@ -13,6 +13,7 @@ Up Next: The Rest: +* Auto-save on focus change or quit * Implement EWMH hooks to prevent window manager killing client with modifications * Implement X Selection protocol for handling clipboard and primary selections * add a distinct state for pointer move versus drag diff --git a/libedit/view.c b/libedit/view.c index 0c43c07..f25822d 100644 --- a/libedit/view.c +++ b/libedit/view.c @@ -345,10 +345,14 @@ void view_selword(View* view, size_t row, size_t col) { } void view_selprev(View* view) { - buf_loglock(&(view->buffer)); - Sel sel = view->selection; - buf_lastins(&(view->buffer), &sel.beg, &sel.end); - view->selection = sel; + if (!num_selected(view->selection)) { + buf_loglock(&(view->buffer)); + Sel sel = view->selection; + buf_lastins(&(view->buffer), &sel.beg, &sel.end); + view->selection = sel; + } else { + view->selection.beg = view->selection.end; + } } void view_select(View* view, size_t row, size_t col) { -- 2.54.0