-
Notifications
You must be signed in to change notification settings - Fork 18
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
Inserting newline places closing brace at wrong indentation level #9
Comments
Auto-pairs doesn’t handle the indentation by itself, but triggers the normal hooks. When inserting a new-line, it goes up and inserts a new-line. |
hm, indeed, I didn't noticed that before, because mainly inserted closing pair at right indentation already. Sorry for wrong issue report, but where should I dig then? |
Hm, maybe on Kakoune directly. |
Which language is concerned? |
c-family |
Does it repro with minimal kakrc and latest commit from this master? Doesn't seem to repro for me, also (finally working) unit tests are green and there are a couple of tests for a similar example. |
yes. Fully empty kakrc, and manual sourcing auto-pairs still produces this issue for |
What OS do you use? Can you clone this repo and run unit tests, and tell me if any of them fail?
|
I've re-cloned the repo, and issue is still here. tests log:
|
Weird! My setup is very similar to yours and I don't repro. If you want to help investigate, consider adding a test for your exact example and confirming that this unit test fails, because it's reeeeeally suspicious. |
strangely enough the test I've wrote passes just fine. |
I wish I could help but I really have no clue how to investigate this if it doesn't repro via unit tests and on my machine with the same OS and shell as you 😞 |
this also happens for me in termux. I'll try to do fresh install of something like ubuntu in VB and try there to see if it is reproduces. |
Managed to reproduce! So it happens only if you run
If I have this, it works fine. If I comment this and run I have no clue as to why. @alexherbo2? But presumably |
Maybe a race condition with the execution of hooks between the languages and auto-pairing. |
@maximbaz personally I don't run this command in Using your hook it works fine. But I tend to disable this automatic pair insertion time to time, as sometimes it just not what I want. In rare cases, but still. |
Also using |
Yeah, so if I turn auto pairs |
Not sure if this can be solved in a meaningful way in the plugin itself. Was thinking about something like this to ensure auto-pairs' hooks are first:
But it feels hacky, also with |
It’s a problem that should be addressed upstream. |
I cam here to report this exact issue. Can anyone describe in more detail what is the problem? |
Seems like if plugin defines it's hooks before filetype hooks the order for executing hooks is correct. Solution for now is to activate plugin by such hook:
Well I guess then you should adress it upstream as a maintainer? I'm not sure how to do it properly since I don't know deep enough how your plugin is working, and what's actually causing an issue here. |
Even without auto-pairs, the indentation is wrong. The indentation is false when inserting a new line between braces. The indentation is not corrected when inserting the closing brace at the beginning of the line. |
I know that there are problems with lisp filetype indentation (it adds extra space on every line for some reason), but for c-family I was pretty much pleased with indentation handling most of the time. |
I can add a fix, but there is two bugs that should be corrected in C-family before. |
I assume this is still waiting on mawww/kakoune#2590? |
I don't think that this issue is related |
@andreyorst 6abc67f Does it help? |
it looses indentation. Cursor is placed correctly though. With this hook int main() {|}
RET
int main() {
|
} after 2
|
I don’t know how to solve the hook execution order. |
Actually, because of this long standing issue I've stopped using auto pairs in all editors :D But your solution for surrounding is outstanding and I use this plugin for it every day. |
Wow thanks |
only
[]
and various quotes are expanding normally with newline.The text was updated successfully, but these errors were encountered: