diff --git a/visidata/_input.py b/visidata/_input.py index d365856eb..8a6031a5e 100644 --- a/visidata/_input.py +++ b/visidata/_input.py @@ -251,8 +251,8 @@ def handle_key(self, ch:str, scr) -> bool: v += c 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 + if self.value == edit_v: + # leave cell unmodified when the editor exits with no change raise EscapeException(ch) else: self.value = edit_v diff --git a/visidata/features/sysedit.py b/visidata/features/sysedit.py index 90da2b04c..89a434871 100644 --- a/visidata/features/sysedit.py +++ b/visidata/features/sysedit.py @@ -37,8 +37,17 @@ def syseditCells_async(sheet, cols, rows, filetype=None): tempcol = tempvs.colsByName.get(col.name) if not tempcol: # column not in edited version continue - col.setValuesTyped(rows, *[tempcol.getTypedValue(r) for r in tempvs.rows]) - - -TableSheet.addCommand('^O', 'sysedit-cell', 'cursorCol.setValues([cursorRow], vd.launchExternalEditor(cursorDisplay))', 'edit current cell in external $EDITOR') + # only assign values that were changed by the editor + edited_rows = [] + edited_vals = [] + for r, r_edited in zip(rows, tempvs.rows): + v = tempcol.getDisplayValue(r_edited) + if col.getDisplayValue(r) != v: + edited_rows.append(r) + edited_vals.append(v) + if edited_rows: + col.setValuesTyped(edited_rows, *edited_vals) + + +TableSheet.addCommand('^O', 'sysedit-cell', 'cd = cursorDisplay; e = vd.launchExternalEditor(cd); cursorCol.setValues([cursorRow], e) if e != cd else None', 'edit current cell in external $EDITOR') Sheet.addCommand('g^O', 'sysedit-selected', 'syseditCells(visibleCols, onlySelectedRows)', 'edit rows in $EDITOR')