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 hare new line insert indentation after comments #4785

Merged
merged 1 commit into from
Mar 13, 2023

Conversation

stacyharper
Copy link
Contributor

@stacyharper stacyharper commented Nov 19, 2022

At the moment, inserting a new line while being in a comment result in a //<indentation> instead of <indentation>//.

To fix this, we just re-ordre both InsertChar hooks.

before
after

hook window InsertChar \n -group hare-insert hare-insert-on-new-line
hook window InsertChar \n -group hare-indent hare-indent-on-new-line
Copy link
Contributor

Choose a reason for hiding this comment

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

I remember that the hook order was relevant for some other reason, and that we are not consistent about that.
IIRC for the more complex file types it's convenient to use a certain hook order, for others it doesn't matter.

Probably the hare module would be better of staying closer to established filetypes. For example, go.kak does not have this problem despite using the same hook order

hare-insert-on-new-line includes a snippet that does

# remove trailing whitespace on the above line

Other filetype highlighter seem to have the same feature but implemented in a different way.
That function could probably just be (untested)

define-command -hidden hare-insert-on-new-line %{ evaluate-commands -draft -itersel %{
    # copy // comments prefix and following white spaces
    try %{ execute-keys -draft <semicolon><c-s>kx s ^\h*\K/{2,}\h* <ret> y<c-o>P<esc> }
} }

At the moment, inserting a new line while being in a comment result in a
"//<indentation>" instead of "<indentation>//".

To fix this, we just paste the comment and indent after the newline
initial indentation.
@stacyharper
Copy link
Contributor Author

stacyharper commented Nov 20, 2022 via email

@krobelus
Copy link
Contributor

the initial version has been merged with 5314e23. Fair enough

@mawww mawww merged commit 86dc413 into mawww:master Mar 13, 2023
greenfork added a commit to greenfork/kakoune that referenced this pull request Jun 4, 2023
Previously was changed in

mawww#4785

Probably some race condition that right now works with a big letter P?
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.

None yet

3 participants