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

fix: use user command lines ranges #825

Merged
merged 2 commits into from
Jan 28, 2025

Conversation

ldelossa
Copy link
Contributor

@ldelossa ldelossa commented Jan 27, 2025

This PR is in response to: #807 (comment)

This is a follow to making line selections work via the command line.

The crux of the confusion with this is that entering the command line from any other mode then normal, exits that mode, and enters normal mode.

Octo was trying to determine a selected line range, retroactively, when adding review comments. However, this doesn't really work since if you highlight a line, then want to run the comment add command, you exit visual mode. All 'state' related to visual mode and visual line rages are greedy and never 'reset' to 0 when visual mode is exited.

The "right" way that Vim intends you to figure out if a user command is being ran with a visual selection is by using the options dictionary provided to the command.

Octo has a object/action lookup mechanism which hides this user command options dictionary from the handlers.

This commit tries to fix the above issue without change how every single object/action is called by creating a global variable OctoLastCmdOpts which caches the last command's options. This can be used to gather the line range in which teh command was called.

Ideally, the object/action function dispatch function is updated to pass the user-command dictionary to all command handlers, but this is a larger change.

Describe what this PR does / why we need it

Does this pull request fix one issue?

Describe how you did it

Describe how to verify it

Special notes for reviews

Checklist

  • Passing tests and linting standards
  • Documentation updates in README.md and doc/octo.txt

@ldelossa ldelossa force-pushed the fix/use-user-command-line-ranges branch from a60a757 to 6bca5a5 Compare January 27, 2025 23:08
@ldelossa
Copy link
Contributor Author

Testing a comment from Octo...

@ldelossa ldelossa force-pushed the fix/use-user-command-line-ranges branch 2 times, most recently from 7034a7f to f1ecfb2 Compare January 27, 2025 23:22
This is a follow to making line selections work via the command line.

The crux of the confusion with this is that entering the command line
from any other mode then normal, exits that mode, and enters normal
mode.

Octo was trying to determine a selected line range, retroactively, when
adding review comments. However, this doesn't really work since if you
highlight a line, then want to run the comment add command, you exit
visual mode. All 'state' related to visual mode and visual line rages
are greedy and never 'reset' to 0 when visual mode is exited.

The "right" way that Vim intends you to figure out if a user command is
being ran with a visual selection is by using the options dictionary
provided to the command.

Octo has a object/action lookup mechanism which hides this user command
options dictionary from the handlers.

This commit tries to fix the above issue without change how every single
object/action is called by creating a global variable `OctoLastCmdOpts`
which caches the last command's options. This can be used to gather the
line range in which teh command was called.

Ideally, the object/action function dispatch function is updated to pass
the user-command dictionary to all command handlers, but this is
a larger change.

Signed-off-by: ldelossa <[email protected]>
@ldelossa ldelossa force-pushed the fix/use-user-command-line-ranges branch from f1ecfb2 to ad33db5 Compare January 27, 2025 23:26
@ldelossa ldelossa marked this pull request as ready for review January 27, 2025 23:26
@ldelossa ldelossa mentioned this pull request Jan 28, 2025
2 tasks
@wd60622
Copy link
Collaborator

wd60622 commented Jan 28, 2025

@raulchen can you test this out and see if it fixes

Copy link
Contributor

@raulchen raulchen left a comment

Choose a reason for hiding this comment

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

Yes, works fine for me.

@wd60622 wd60622 merged commit 02cd8aa into pwntester:master Jan 28, 2025
3 checks passed
@wd60622
Copy link
Collaborator

wd60622 commented Jan 28, 2025

Thanks for the quick fix

@ldelossa ldelossa deleted the fix/use-user-command-line-ranges branch January 28, 2025 21:10
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