Skip to content

Commit

Permalink
[input-] preserve None cells on external editor quit
Browse files Browse the repository at this point in the history
  • Loading branch information
midichef authored and anjakefala committed Oct 28, 2024
1 parent 3e10140 commit 77a43da
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion visidata/_input.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 77a43da

Please sign in to comment.