diff --git a/tests/golden/pr2614.tsv b/tests/golden/pr2614.tsv new file mode 100644 index 000000000..296d65103 --- /dev/null +++ b/tests/golden/pr2614.tsv @@ -0,0 +1,4 @@ +A +1 +2 +3 diff --git a/tests/pr2614.vdj b/tests/pr2614.vdj new file mode 100644 index 000000000..394ebdf51 --- /dev/null +++ b/tests/pr2614.vdj @@ -0,0 +1,6 @@ +#!vd -p +{"sheet": null, "col": null, "row": null, "longname": "open-file", "input": "tests/data1.tsv", "keystrokes": "o", "comment": null, "replayable": true} +{"sheet": "data1", "col": "Key", "row": "", "longname": "hide-col", "input": "", "keystrokes": "-", "comment": "hide the current column", "replayable": true} +{"sheet": "data1", "col": "A", "row": "", "longname": "hide-col", "input": "", "keystrokes": "-", "comment": "hide the current column", "replayable": true} +{"sheet": "data1", "col": "B", "row": "", "longname": "hide-col", "input": "", "keystrokes": "-", "comment": "hide the current column", "replayable": true} +{"sheet": "data1", "col": 0, "row": "", "longname": "addcol-incr", "input": "", "keystrokes": "i", "comment": "add column with incremental values", "replayable": true} diff --git a/visidata/sheets.py b/visidata/sheets.py index 782f68bf5..daa9fe351 100644 --- a/visidata/sheets.py +++ b/visidata/sheets.py @@ -576,7 +576,10 @@ def addColumnAtCursor(self, *cols): index = 0 ccol = self.cursorCol if ccol and not ccol.keycol: - index = self.columns.index(ccol)+1 + try: + index = self.columns.index(ccol)+1 + except ValueError: # when all columns are hidden, the one column shown is not in self.columns + index = 0 self.addColumn(*cols, index=index) firstnewcol = [c for c in cols if not c.hidden][0]