-
Notifications
You must be signed in to change notification settings - Fork 1.7k
feat: Add vscode native onEnterRules #10384
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
Conversation
Do these still not work when declared in the JSON? |
I didn't try. Does it matter? |
Not too much, but doing it the declarative way and having less client code seems slightly nicer. But I wouldn't block this PR on it. Oh well... r? @matklad |
Oh, so we actually can do this programmatically? Then let's make sure that it is possible to enable only one of custom onEnter or native on enter, and use the native one by default. That is, what we want to avoid is them both being enabled and fighting each other, which I beleive can happen if we just unconditionally enable this? |
Can we actually check that ours is enabled? |
Even if we don't, we can just add a config to disable registration of native handles. |
They will fight each other? I checked and it was not a problem (And I expected it because shortcut eats enter key completely). I also checked the multi-cursor, which did not work properly, but I do not think it is due interference. I just checked simple cases, if you have a special case tell me to check. That said, make it disable-able has no cost, if there is benefit in it I can do it. By the way, I noticed that RA adds |
If ther's no conflict, then r=me!
Probably not -- the logic for |
I think there isn't. But it is good to someone else double check it.
👍 By the way, lsif PR is also ready for review. |
bors r=matklad,lnicola |
I believe this has recently made doc comments ( I attempted to check if the |
It isn't disable-able on RA (an option can simply added) and surprisingly nor on code. I wonder why you want to disable it? |
It's mostly about being accustomed to writing comments manually and how I typically write doc comments before definitions. When creating a new item (be it a struct, function, trait, etc...), I typically first put a single line doc comment to explain what it is, and then I write it's definition. With the auto continue, after pressing enter I get another doc comment and have to first delete it before typing the definition. I could probably write the definition first and then write the doc comment, but I think it helps me to follow the definition off the doc comment and not backwards. |
Many of my doc comments are no longer than 2 lines. This means the heuristic for adding Conversely, I often write long regular I wonder why you think that you can automatically infer whether the programmer wanted to continue the comment vs continue writing code after the comment? I don't think there is a reliable way to detect that, and any attempt at being 'smart' here will just frustrate programmers. The way Also see #12928. |
Enter is not the only key that can be used to finish the doc comments. Specially in my flow, signature then doc then body, enter is wrong and I should use arrow keys even if r-a doesn't add That said, I really understand that some people may not like this behavior, and I have no objections against making it configurable. Ideally, it should be configurable at vscode level, because if you don't like this behavior in r-a, you probably don't like it in other languages (js, java, c#, ...) and in other language servers (rls) as well, and this PR changes is vscode specific, so I think it worth raising an issue there (they might now a way to disable it). Meanwhile it should be possible to add a configuration for it in r-a, I even tried to do it after @Zenithsiz comment, but it needed more effort than what I was able/interested to put on this. |
So you are writing code not in the order in which it appears in the file? Sure, you do you, but please don't assume everyone works like that. :)
If I understand correctly, what you are doing here is (ab)using the rules for adding indentation in new lines to also add comments. I am not objecting at all to adding indentation, that is almost always correct. The issue stems from using the auto-indent mechanism for something else, namely auto-commenting. A vscode setting would probably also remove the auto-indentation and that would not be the right behavior. (Or maybe I am misunderstanding, the implementation details of vscode are completely foreign to me.) I am not using vscode for any other languages so I don't know how this is handled there. |
Fair :) but down arrow key is still an option.
No, |
Not sure what you mean, how can I use the down arrow key to add a newline without adding ///! My great comment.<|>
and want to go on typing |
This PR copy onEnterRules configurations from vscode-rust based on discussion in #6254
I understand that the ideal way is to use parser data for this, and probably all other things that language-config do. But since it can't be enabled (or at least it isn't enabled) by default in vscode, I think this is needed (until onEnter becomes official LSP and get vscode support).
People can still configure shortcut and use the parser based onEnter, so it wouldn't harm anyone.