visidata
visidata copied to clipboard
[main-] handle position args as +sheet:subsheet:col:row
Two bug fixes:
3ea655baacc1ebe7ac2c4488d938aadb26dd8b9e - fixes setting column position in sheet
Currently the starting column cannot be set, only the row.
repro command: vd sample_data/sample.tsv sample_data/StatusPR.csv +2:2
This occurs because the column position changes too early, before the sheet is loaded.
1aa2d9808d79d89810bf1837d39b5f89b71d83f5 - fixes setting column position in subsheet
A similar problem, changing position before the subsheet is loaded.
repro: vd ~vdsrc/sample_data/employees.sqlite +:emp:5:2
And then some functionality changes:
d16743d96114949aafb6f63b507ed01125f31406 - change arg parsing, from row:col to col:row
Strings of the form a:b are parsed as row:column. This commit changes it to column:row.
Previously, I discussed some pros and cons of this change.
This is technically a breaking change, but as I noted in that comment, the form +a:b
has not worked since 2.9 so it's not likely that anyone is currently using that syntax. However, if they are using +:a:b
with the extra colon, this will indeed be a breaking change for them.
repro: vd ~vdsrc/sample_data/sample.tsv +:1:4
(note the :
before the 1
. It's needed (on develop
) to demonstrate the column-positioning bug, until the 2 commits above are applied.)
0a8f6ee3ca4b1b62fb514fbec7eb29e4c3b9b20b - handling args of form +a:b
vs +:a:b
.
Comments in the code suggest that '+col:row' should apply to only the last sheet on the list, vs. adding a colon, '+:col:row', which should apply to all sheets:
https://github.com/saulpw/visidata/blob/c01c2b5fe506632590c8d7f5bcf23b1afe9c1985/visidata/main.py#L90
(The suggestion comes from the phrase Empty sheetstr in startsheets
. An empty sheetstr
happens only when arg.split(':')
has more than 2 items and pos[:-2]
is ''
, which happens when arg
follows the pattern +:a:b
:
https://github.com/saulpw/visidata/blob/c01c2b5fe506632590c8d7f5bcf23b1afe9c1985/visidata/main.py#L105
Currently the behavior is the reverse: +col:row applies to all sheets.
repro: vd sample_data/sample.tsv sample_data/StatusPR.csv +:2:2
and look at the cursor position on each sheet.
This commit changes +:a:b
to apply to all sheets, and +a:b
to apply only to the last sheet.
da52ac3b7b72243e25bfd4cb8e85bb95dd4eb9be - improve error for invalid sheets
Attempting to index a sheet that does not exist, as with:
repro: vd sample_data/sample.tsv +10:0:0
gives a traceback with IndexError: list index out of range
.
This commit handles the error and shows a status message of no sheet "10"
.
a0d4913a94d7147975c28eb3ec3ceb8014addc66 - handling subsheet names that are integers
For consistency with sheets/rows/cols, this commit allows indexing subsheets with integers, like:
numeric-subsheet-names.vds.txt
repro: vd -f vds numeric-subsheet-names.vds.txt +0:3:0:0
This is also a change that breaks current behavior, for a subsheet that happens to have a name that is an integer. Such a subsheet would become unable to opened by using its name, as with sheets 5
, 6
, 7
, and 8
in numeric-subsheet-names.vds.txt
; +0:5:0:0
currently works, but after this commit only +0:0:0:0
would work.
Thoughts? I'm not so worried about breaking changes, because I don't think the vd +
feature is heavily used.
Just to write out all the cases, here's what the args would mean after all these commits:
+2 = row 2
+1: = last sheet; col 1
+:1: = all sheets; col 1
+:2 = last sheet; row 2
+1:2 = last sheet; col 1, row 2
+:1:2 = all sheets; col 1, row 2
+0:1:2 = sheet 0; col 1, row 2
+:a:1:2 = last sheet, subsheet a; col 1, row 2
+0:a:1:2 = sheet 0, subsheet a; col 1, row 2
+0:a:b:1:2 = sheet 0, subsheet a from sheet 0, subsheet b from sheet a; col 1, row 2
+0:0:1:2 = sheet 0, first subsheet of sheet 0, col 1, row 2
+1:: = 2nd sheet, col 0, row 0
+-2:: = 2nd sheet from last, col 0, row 0