Skip to content
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

[sheets-] record key-col toggle for replay as key-col-on/-off #2622

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from

Conversation

midichef
Copy link
Contributor

@midichef midichef commented Dec 3, 2024

I'm following up on @saulpw's comment about trouble caused by keycol toggling in cmdlog replay.

it's tricky to change behavior based on existing column state, as this can make cmdlog replay a lot less predictable. We already have this with e.g. key-col and it's caused some problems. Maybe the ultimate answer is to have key-col put a more precise command like key-col-on or key-col-off (please help come up with better longnames if we do this) on the cmdlog.

Does the problem with key-col for cmdlog-replay still exist? If so, this PR should fix it, by recording key-col-on or key-col-off instead of key-col.

I'm preparing to submit the feature proposed in that Discussion: changing a column's sort direction while preserving other column's sort direction. So if this kind of fix is still needed for key-col, then I'll apply the same idea to sort-asc and the commands like it.

Copy link
Owner

@saulpw saulpw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It hadn't quite occurred to me to do it this way, but you know what, I'll take it. Nice job.

@midichef
Copy link
Contributor Author

midichef commented Dec 3, 2024

Hmm, this PR still needs work. I hadn't thought about the case of macros.

With this change, when key-col is used in a macro, the macro will contain two commands, the original key-col and key-col-on (or -off). So that needs a fix.

But there's also a UI difference between macros and replay logs that makes this approach difficult. Users may expect ! in a macro to perform toggling. Whereas in a cmdlog replay file that's only replayed once, what is desired is setting the keycol state, not toggling.

@midichef
Copy link
Contributor Author

midichef commented Dec 18, 2024

With this change, when key-col is used in a macro, the macro will contain two commands, the original key-col and key-col-on (or -off). So that needs a fix.

Okay I've fixed this problem. However, users who use macros to replay movement commands will find that this change breaks that use case. Commands like go-left are already excluded from command logs, and this PR now excludes them from macros.

To save movement commands in macros, add this to .visidatarc:

for longname in ['go-left', 'go-right',
                 'go-down', 'go-up',
                 'go-left-page', 'go-right-page'
                 'go-pagedown', 'go-pageup' ]:
    for sheet_type, cmd in vd.commands.get[longname]:
        cmd.replayable = True

@midichef midichef force-pushed the record_no_keycol_toggle branch from 1842955 to 42a4773 Compare December 26, 2024 18:32
@midichef
Copy link
Contributor Author

Oops, I just noticed that when I force-pushed the followup commit for macros, I had deleted my original commit about keycols. I've just brought it back as 7e1ecbd. It is unchanged, except for rebasing it onto the latest develop branch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants