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

[BUG] comment-line sometimes does not comment filetype=sh #5096

Open
sdothum opened this issue Jan 29, 2024 · 3 comments
Open

[BUG] comment-line sometimes does not comment filetype=sh #5096

sdothum opened this issue Jan 29, 2024 · 3 comments
Labels

Comments

@sdothum
Copy link

sdothum commented Jan 29, 2024

Version of Kakoune

v2023.08.05

Reproducer

Execute :comment-line on selected lines

Outcome

comment-line on occasion with shell scripts (whose filetype is set via modeline-prompt) will complain: "the 'commert_line' option is empty, could not comment the line".

Expectations

Comment/uncomment line.

Additional information

comment.kak, while setting the commert_line option to '#' by default, appears to have this unset during buffer loading (perhaps a timing conflict with modeline-prompt?).

The solution was to modify comment.kak. I simply changed the hook for filetype=conf to filetype=(conf|sh)

@sdothum sdothum added the bug label Jan 29, 2024
@krobelus
Copy link
Contributor

there is at least one issue when the filetype is first something like markdown and then sh

Can you reproduce wiht this in your kakrc:

hook global BufSetOption filetype=.* %{
    echo -debug setting %val{hook_param}
}
hook global BufSetOption comment_line=.* %{
    echo -debug setting %val{hook_param}
}

and post the contents of the debug buffer.

The conf hook is already a hack; ideally resetting the option when a filetype gets unset works for all filetypes, even the empty one.
We have the same problem with some other hooks.
One problem is hook ordering, maybe we should have a hook -first option so "scope end" style hooks run before others.

@sdothum
Copy link
Author

sdothum commented Jan 30, 2024

Here is the requested debug output..

*** This is the debug buffer, where debug info will be written ***
setting comment_line=
setting filetype=html
setting filetype=sh
setting filetype=sh
setting comment_line=
kak-lsp: config-change detected: 
. . .

with the stock comment.kak (without the hook for filetype=sh that i added) opening a script which sets the filetype with modeline-prompt.

i opened this file and attempted to immediately comment the first line.

@krobelus
Copy link
Contributor

I'm working on a fix, my current approach is to add a BufSetOptionPre hook so each filetype hook can unset what it did without BufSetOption hooks having to worry.

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

No branches or pull requests

2 participants