-
-
Notifications
You must be signed in to change notification settings - Fork 276
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
[sort] sort ordering is improperly copied in copy() #2190
Comments
So, the sort ordering is intended to be modular, which is why Let's try making Extensible newcopy not call the initializer if the attribute already exists (I just committed/pushed this). Your commit should work then. If not, we can let go of the above ideal, and remove the |
Okay, that makes sense, thanks for explaining the design goals. The Extensible change works, so, I'll push a slightly modified version of the commit. I'd forgotten to handle the case where the sort column is a string. |
move Sheet._ordering initializer to Sheet.__init__ instead of using Extensible
Small description
When I set a sort direction with
[
and copy a sheet (as with"
), the sort direction disappears in the new sheet,.Expected result
I expect the sort columns to be preserved in the copy. Or to disappear in all cases.
Actual result with screenshot
Any ordering I create myself, is lost.
But some orderings are preserved in the copy, the built-in ones that use a column name (a string), instead of the column object. Like FreqTableSheet's
'count'
.Steps to reproduce with sample data and a .vd
Assign a sort direction to any column with
[
and duplicate the sheet withg"
. The sort direction will not exist on the new sheet.Additional context
visidata 2.11.1 and v3.0dev
The sort ordering is preserved across a copy, but too literally. After
copy()
,sheet._ordering
contains columns, but they are the column objects from the source sheet, not the ones in the new copy. I can try to reconstruct the appropriate_ordering
, like so:f7bd9ef
But I run into a problem. The
_ordering
I make is later overwritten with an empty list. It happens becauseExtensible.init()
runs theinitfunc
for_ordering
, which islist
. How should I handle that?The text was updated successfully, but these errors were encountered: