From 77a43da60b70bd14ad40412882b00b54cad806e8 Mon Sep 17 00:00:00 2001 From: midichef <67946319+midichef@users.noreply.github.com> Date: Sat, 26 Oct 2024 01:32:08 -0700 Subject: [PATCH] [input-] preserve None cells on external editor quit --- visidata/_input.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/visidata/_input.py b/visidata/_input.py index 7c56ff060..0bef336e5 100644 --- a/visidata/_input.py +++ b/visidata/_input.py @@ -249,7 +249,14 @@ def handle_key(self, ch:str, scr) -> bool: c = vd.prettykeys(c) i += len(c) v += c - elif ch == '^O': self.value = vd.launchExternalEditor(v); return True # auto-accept after $EDITOR + elif ch == '^O': + edit_v = vd.launchExternalEditor(v) + if self.value == '' and edit_v == '': + # if a cell has a value of None, keep it when the editor exits with no change + raise EscapeException(ch) + else: + self.value = edit_v + return True elif ch == '^R': v = self.orig_value # ^Reload initial value elif ch == '^T': v = delchar(splice(v, i-2, v[i-1:i]), i) # swap chars elif ch == '^U': v = v[i:]; i = 0 # clear to beginning