-
-
Notifications
You must be signed in to change notification settings - Fork 283
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[main-] handle position args as +sheet:subsheet:col:row #2425
base: develop
Are you sure you want to change the base?
Conversation
I fixed the type hint that was breaking in Python 3.8, by adding Line 50 in c01c2b5
|
visidata/main.py
Outdated
sheets = sources # apply row/col to all sheets | ||
sheets = sources # apply col/row to all sheets | ||
for vs in sheets: | ||
vd.sync(vs.ensureLoaded()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So, the problem with this sync, is that opening a large file with a start position specified, will wait until the entire file has loaded, before it shows any interface at all. (Prior to this change, it loads the file immediately and reports that it can't find the column).
Neither behavior is what the user wants, but the current behavior is at least immediately responsive, whereas adding a sync() here will appear to delay startup indefinitely, with no feedback.
My proposed behavior, would be to wait a second or two after loading on the sheet has started (or until loading has finished, if that's sooner), before trying to move the cursor. This will fix the issue in most cases, since columns are usually discovered very early in the loading process. If the column hasn't been discovered yet, it will fail as it does currently. Alternatively, we could start a thread that keeps trying to move the cursor to the given starting position until it either succeeds, or loading has finished.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point, responsiveness is critical. I'll think about how to implement it. I do like the idea of a thread that keeps trying. Because then the delay before the cursor move could be shorter than a second, and unobtrusive.
(This is a large combined PR, so I'm posting my comments piecemeal.) I agree with your comments in #2358, that it should be I'm less enthusiastic about |
It should apply to the most recently specified sheet on the CLI, and not the last sheet. So you could specify a different position for each sheet:
vs
such that the row movement would be different for the two sheets, but they should both end up on the I would prefer to specify "all sheets" more explicitly, like |
BTW, @midichef, thank you so much for calling out all the different cases. We should lift that and put it directly into the docs, both the manpage and the online .md. |
I thought about this syntax some more. Here are a few arguments against
And changing the behavior would be easy. It is a one-line change. But if we get rid of |
Here's the design and explanation that I think is coherent: The core design for this option is Values are interpreted right-to-left, with an empty sheet field meaning "all" and a missing field meaning "current". So This also means that I believe the above is entirely consistent with your given examples, so it feels like we're converging on the design. Open question: can we use Does this leave anything unspecified or unclear? |
It's clear, thanks! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we're still waiting on changes for the last comment about vd.sync().
I've almost got a final patch ready to remove unnecessary
@anjakefala How do I update the manual pages in |
@midichef Just update |
Before this PR, for the purposes of the As this PR currently stands, changing to What's the right base to use for numbering rows and columns? |
Sure, I'll put that in too. |
Let's use 0-based numbers for both, consistent with Python. |
Removes unused code that passed wrong type to Path: "Path(inputs[-1])"
This handles the case where the sheet is the empty string, and a subsheet is specified.
Previously, moveToRow() would return True, and set the cursor row index to the nonexistent row, with no visible errors. For slow loading sheets, checkCursor() could then move the cursor to an earlier row.
Okay, I've incorporated all the feedback. This set of commits will retry the move changes every 0.1 seconds. It's hardcoded. Should I make this a configurable option? Also, it will retry failed moves forever. Should there be a time limit? Or a number of failures limit? The repeated errors are annoying and currently make it impossible to leave the sheet that is giving errors: I could also use some guidance on the troff/groff formatting. Existing |
Using int indices internally is better than using sheet names, because sheet names were ambiguous when sheets had the same name, for example, the name "sample" in: vd sample.tsv b.tsv sample.json +1:2
Two bug fixes:
3ea655b - 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.
1aa2d98 - 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:
d16743d - 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 the1
. It's needed (ondevelop
) to demonstrate the column-positioning bug, until the 2 commits above are applied.)0a8f6ee - 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:
visidata/visidata/main.py
Line 90 in c01c2b5
(The suggestion comes from the phrase
Empty sheetstr in startsheets
. An emptysheetstr
happens only whenarg.split(':')
has more than 2 items andpos[:-2]
is''
, which happens whenarg
follows the pattern+:a:b
:visidata/visidata/main.py
Line 105 in c01c2b5
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.da52ac3 - 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"
.a0d4913 - 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
, and8
innumeric-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: