| Summary: | [content assist] Allow to disable auto insertion trigger characters | ||||||||
|---|---|---|---|---|---|---|---|---|---|
| Product: | [Eclipse Project] JDT | Reporter: | raelg <raelg77> | ||||||
| Component: | Text | Assignee: | Mickael Istria <mistria> | ||||||
| Status: | VERIFIED FIXED | QA Contact: | |||||||
| Severity: | enhancement | ||||||||
| Priority: | P3 | CC: | BrainSlugs83, butaio, cskfy, daniel_megert, dario.arena87, erik.hansson, fabian.pfaff, gautier.desaintmartinlacaze, hvictor, jeremie, k.electron, khjgfty4regrdhg, Lars.Vogel, liyouhuan2007, manju656, markus.kell.r, mistria, noopur_gupta, pascal.seitz, timo.kinnunen, tom.devel, zanetu | ||||||
| Version: | 3.7 | Keywords: | Documentation, noteworthy | ||||||
| Target Milestone: | 4.10 M3 | ||||||||
| Hardware: | All | ||||||||
| OS: | All | ||||||||
| See Also: |
https://git.eclipse.org/r/24199 https://bugs.eclipse.org/bugs/show_bug.cgi?id=538815 https://bugs.eclipse.org/bugs/show_bug.cgi?id=537873 https://git.eclipse.org/r/129618 https://git.eclipse.org/c/jdt/eclipse.jdt.ui.git/commit/?id=0b7dfe14f86da01c63a736d7a22858b078fe1e8c https://git.eclipse.org/r/132278 https://git.eclipse.org/r/132280 https://git.eclipse.org/c/platform/eclipse.platform.common.git/commit/?id=f12e79ab6f5cf397534d034eb597820985321d74 https://git.eclipse.org/c/www.eclipse.org/eclipse/news.git/commit/?id=8e21d593b0c73ddc4bf2367805e7715f1e6223a2 |
||||||||
| Whiteboard: | |||||||||
| Bug Depends on: | 539165 | ||||||||
| Bug Blocks: | 508789 | ||||||||
| Attachments: |
|
||||||||
|
Description
raelg
>automatically inserted upon pressing ; which is usually wrong for parameter
>name suggestions.
Why to you press ';' then?
(In reply to comment #1) > >automatically inserted upon pressing ; which is usually wrong for parameter > >name suggestions. > Why to you press ';' then? because java statements terminate with ; ?? (In reply to comment #2) > > (In reply to comment #1) > > >automatically inserted upon pressing ; which is usually wrong for parameter > > >name suggestions. > > Why to you press ';' then? > > because java statements terminate with ; ?? Right, but your not in a statement probably but triggered content assist automatically at the wrong location because you entered all chars as auto-activation triggers. There's no setting that lets you change this behavior. (In reply to comment #3) > (In reply to comment #2) > > > > (In reply to comment #1) > > > >automatically inserted upon pressing ; which is usually wrong for parameter > > > >name suggestions. > > > Why to you press ';' then? > > > > because java statements terminate with ; ?? > > Right, but your not in a statement probably but triggered content assist > automatically at the wrong location because you entered all chars as > auto-activation triggers. > > There's no setting that lets you change this behavior. I thought this was the place to raise change requests for unexpected behaviour. I really believe implementing something like this will result in a significant increase in productivity. Switching from Xcode or Visual Studio to Eclipse makes Eclipse development seem incredibly inefficient. Currently content assist is not targeted for the scenario where one adds all characters as triggers and we currently don't plan to work on this. If someone wants to offer an option to disable ';' as auto-insertion character then I'm fine with that. (In reply to comment #5) > Currently content assist is not targeted for the scenario where one adds all > characters as triggers and we currently don't plan to work on this. > > If someone wants to offer an option to disable ';' as auto-insertion character > then I'm fine with that. time pending, it is something I can look at. As a quick fix can you point me in the correct direction to write a plugin which overrides the default behaviour? > As a quick fix can you point me in
> the correct direction to write a plugin which overrides the default behaviour?
There's no way to do this from the outside.
*** Bug 420425 has been marked as a duplicate of this bug. *** Those triggers don't work correctly. I've configured content assist to auto-activate from keys ; ,.[(=- but when I write a local variable declaration and want to initialize it, pressing <SPACE>, '=', <SPACE> results in (| marks where caret is): int name name=name |, and the '=' is in wrong place. So I press that again and the end of line becomes: name name=|, now the space is not where it should be! So I press that again which results in: name=name |, now the assignment is not correct, so I press that again, and so on and so on... Start with: /* indent here */ String[] \u000a_ALL_WORK_AND_NO_PLAY_MAKES_JACK_A_DULL_BOY| and soon you workspace is full of: /* indent here */ String[] \u000a_ALL_WORK_AND_NO_PLAY_MAKES_JACK_A_DULL_BOY ALL_WORK_AND_NO_PLAY_MAKES_JACK_A_DULL_BOY= ALL_WORK_AND_NO_PLAY_MAKES_JACK_A_DULL_BOY ALL_WORK_AND_NO_PLAY_MAKES_JACK_A_DULL_BOY= ALL_WORK_AND_NO_PLAY_MAKES_JACK_A_DULL_BOY ALL_WORK_AND_NO_PLAY_MAKES_JACK_A_DULL_BOY= ALL_WORK_AND_NO_PLAY_MAKES_JACK_A_DULL_BOY | This isn't how content assist auto-activation is supposed to work! (In reply to Timo Kinnunen from comment #9) > Those triggers don't work correctly. The triggers mentioned in bug 420425(if you are referring to those) are meant to select one of the proposal from the pop-up. These trigger characters are fixed and not configurable. Auto activation trigger available in preference page (by default '.') is to activate the content proposal pop-up. Yep, that's where I learned of them. I am kind of cheating by having seen their special status from the code and then using them in a way that maximizes the chances of something going wrong from triggering a data race or an unanticipated interaction in some corner-case. Still, there's nothing in the settings UI which would suggest that some keys are special, that they should not be used for auto-activation or that if they are used for auto-activation then the resulting behavior is unspecified. Nor should there be any of that, because some keys being handled on different code paths internally should not be of concern to the consumer. Created attachment 236956 [details]
In the meantime, a workaround
Here's a small plugin that is used by copying it into your eclipse\dropins -folder.
The plugin disables Content Assist auto-completion trigger keys automatically every time Eclipse starts. In addition there's a toolbar button and a menu item to toggle the disabled keys back on and off. Source code included.
Works great! Thank you so much! I finally got to cleaning up some old changes and came to this plugin, so here is Gerrit https://git.eclipse.org/r/24199 for review. We'll try to review during 4.5. (In reply to Dani Megert from comment #15) > We'll try to review during 4.5. I took a quick look at the Gerrit change: We should offer to set the auto insertion characters like we allow to set the auto activation triggers. The proposed change only allows to disable all at once. Latest Gerrit patch adds the option to both add additional characters and disable existing trigger characters. In addition trigger characters can optionally be used to close Content Assist instead of inserting the selected completion. That feature is a bit of a hack but the implementation seems to stay within the confines of the APIs. *** Bug 433580 has been marked as a duplicate of this bug. *** It is certainly extremely annoying when 'int<space>' autocomplete turns into some 'INTernalWhatnot<space>' on every turn. I remember days, when this wasn't an issue. BUT There is another (and complimentary) solution: - The first suggestion offered by autocomplete should always be the EXACT typed-in words if there is a match. IMHO in addition to creating this patch, there should be another and simple patch for the auto-complete suggestions list. That's just my two cents. Best wishes, Tomas (In reply to comment #19) > - The first suggestion offered by autocomplete should always be the EXACT > typed-in words if there is a match. > > IMHO in addition to creating this patch, there should be another and simple > patch for the auto-complete suggestions list. Haa, guess what my patch does when 'Auto completion resets' option has been selected :) (TBH, it simply alters the current completion to replace the to-be-inserted characters with what you've already typed at the moment auto completion gets triggered, it doesn't add or change existing completions.) Created attachment 252514 [details]
A better workaround (with tab completion!)
Fixes the Auto completion bug in Eclipse Luna SR2 4.4.2.
Changes auto completion to be triggered only pressing Enter or Tab, nothing else.
I recommend using this with an auto-activation delay of 50ms, and the following triggers: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz =.(!+-*/~,[{@#$%^&" (note the inclusion of the space character).
Please, when you implement this, allow for tab to be a valid completion character!! FYI, Timo Kinnunen's work around plug-in doesn't work for me, so I just made my own patch of the relevant code (via this SO answer: http://stackoverflow.com/a/21898810/398630): The jar (with embedded src) can be found at http://1drv.ms/1GZhJPq (also, I've attached it to the bug above) -- just dump it in your plugins folder (you probably want to back up the old file, just in case). The major modification is that in src/org/eclipse/jface/text/contentassist/CompletionProposalPopup.java in the verifyKey method, in the second switch statement: 1.) I disabled the default handler, because it's ridiculous that it tries to insert crap that the user hasn't selected. 2.) I disabled the '\t' handler because '\t' should insert, not switch focus to the auto completion window (up and down work just fine, thank you!) 3.) for the handler above those two (the handler for '\r' and '\n'), I added '\t' to the list. For reference, my auto activation delay is 50ms, and my triggers for Java are: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz =.(!+-*/~,[{@#$%^&" (this includes the space character of course!). *** Bug 453125 has been marked as a duplicate of this bug. *** *** Bug 421440 has been marked as a duplicate of this bug. *** is this bug scheduled to come out anytime soon? im not able to drop in a jar because we dont do that in corp environments. (In reply to Karim Fatehi from comment #25) > is this bug scheduled to come out anytime soon? im not able to drop in a jar > because we dont do that in corp environments. I don't see any relationship to this bug report. (In reply to Dani Megert from comment #26) > (In reply to Karim Fatehi from comment #25) > > is this bug scheduled to come out anytime soon? im not able to drop in a jar > > because we dont do that in corp environments. > > I don't see any relationship to this bug report. sorry, what i meant is, are we going to make it so that the auto inserting triggers will be configurable? i would like to remove space as the acceptance key because i want constant content assist without accepting incorrect choices. *** Bug 500846 has been marked as a duplicate of this bug. *** FYI - This bug was reported as one of the major pain points in using JDT code completion. See thread behind https://dev.eclipse.org/mhonarc/lists/platform-ui-dev/msg07540.html I've encountered this issue too. In java this is somewhat tolerable (but annoying sometimes) but in other languages (I occasionally write some Spock tests using Groovy) this forces me to press "ESC" for every keyword i write or disabling autocompletion at all to avoid wrong keyword being inserted. "Classic" autocompletion works but i think is a little obsolete because i find this autocompletion method much more convenient. To me one big improvement would be disabling autocompletion insertion on SPACEBAR and on SEMICOLON. I've also encountered this bug, and it also happens a space, '(', or '.' is typed, in addition the the already mentioned ';'. From reading through the comments, it seemed as though the issue was going to be fixed, but it never was. Are there still plans to fix this?
Auto completion also automatically activates on the following characters:
protected final static char[] METHOD_TRIGGERS= new char[] { ';', ',', '.', '\t', '[', ' ' };
protected final static char[] METHOD_WITH_ARGUMENTS_TRIGGERS= new char[] { '(', '-', ' ' };
protected final static char[] TYPE_TRIGGERS= new char[] { '.', '\t', '[', '(', ' ' };
protected final static char[] VAR_TRIGGER= new char[] { '\t', ' ', '=', ';', '.' };
Because there are so many different auto-insertion characters, I think that it would be a better idea to add a single option to only insert suggestions with 'Enter', instead of having multiple options to turn off each character.
*** Bug 538815 has been marked as a duplicate of this bug. *** *** Bug 537873 has been marked as a duplicate of this bug. *** I am trying to fix this bug. My proposed fix is: An option under Preferences -> Java -> Editor -> Content assist. The option would be a checkbox, and it would say "Only insert suggestions when enter key is pressed". I would appreciate any help/guidance in fixing this bug (I can't figure out which sources/classes I need). (In reply to bob ross from comment #35) > I am trying to fix this bug. My proposed fix is: > An option under Preferences -> Java -> Editor -> Content assist. The option > would be a checkbox, and it would say "Only insert suggestions when enter > key is pressed". I would appreciate any help/guidance in fixing this bug (I > can't figure out which sources/classes I need). To find the class under the preference pages, you use the plug-in spy http://www.vogella.com/tutorials/EclipsePlatformDevelopment/article.html#plug-in-spy-for-ui-parts. (In reply to bob ross from comment #35) > I would appreciate any help/guidance in fixing this bug (I > can't figure out which sources/classes I need). The place where to change the UI is CodeAssistConfigurationBlock. The place where to change in the "model" is CompletionProposalCollector where you can see the trigger chars for selection of a proposal are hardcoded. A global preference allowing to bypass those hardcoded ones and pass en empty list of trigger chars instead would be fine. Note that you don't need to add the support for "Enter" as it's built-in, here it's only about removing those extra chars. Good luck, and thanks for taking care of this! Feel free to ping on the ticket or on Gerrit reviews whenever necessary. (In reply to bob ross from comment #35) > I am trying to fix this bug. My proposed fix is: > An option under Preferences -> Java -> Editor -> Content assist. The option > would be a checkbox, and it would say "Only insert suggestions when enter > key is pressed". I would appreciate any help/guidance in fixing this bug (I > can't figure out which sources/classes I need). I seems a lot like what was proposed in https://git.eclipse.org/r/#/c/24199/ , and I'd like to influence in getting this patch merged without need for extra settings. Can you please give a try to that patch and see whether it works for your use-case and vote/comment on the Gerrit review accordingly. @Timo: are you still around? Any chance you can rebase your patch? (In reply to Mickael Istria from comment #38) > (In reply to bob ross from comment #35) > > I am trying to fix this bug. My proposed fix is: > > An option under Preferences -> Java -> Editor -> Content assist. The option > > would be a checkbox, and it would say "Only insert suggestions when enter > > key is pressed". I would appreciate any help/guidance in fixing this bug (I > > can't figure out which sources/classes I need). > > I seems a lot like what was proposed in https://git.eclipse.org/r/#/c/24199/ > , and I'd like to influence in getting this patch merged without need for > extra settings. > Can you please give a try to that patch and see whether it works for your > use-case and vote/comment on the Gerrit review accordingly. > @Timo: are you still around? Any chance you can rebase your patch? I am a little confused now: is the bug already fixed and waiting to be merged? (In reply to bob ross from comment #39) > I am a little confused now: is the bug already fixed and waiting to be merged? Oh (In reply to bob ross from comment #39) > (In reply to Mickael Istria from comment #38) > > (In reply to bob ross from comment #35) > > > I am trying to fix this bug. My proposed fix is: > > > An option under Preferences -> Java -> Editor -> Content assist. The option > > > would be a checkbox, and it would say "Only insert suggestions when enter > > > key is pressed". I would appreciate any help/guidance in fixing this bug (I > > > can't figure out which sources/classes I need). > > > > I seems a lot like what was proposed in https://git.eclipse.org/r/#/c/24199/ > > , and I'd like to influence in getting this patch merged without need for > > extra settings. > > Can you please give a try to that patch and see whether it works for your > > use-case and vote/comment on the Gerrit review accordingly. > > @Timo: are you still around? Any chance you can rebase your patch? > > I am a little confused now: is the bug already fixed and waiting to be > merged? Sorry, I did not realize that a patch was already pending. The patch that you linked to is exactly what I was going to do, although we don't need an option to turn off specific characters individually, only an option to turn them all off (except for the 'enter' key) (In reply to bob ross from comment #39) > Sorry, I did not realize that a patch was already pending. Me neither, until a few hours ago ;) > The patch that > you linked to is exactly what I was going to do, although we don't need an > option to turn off specific characters individually, only an option to turn > them all off (except for the 'enter' key) I agree. Can you please at least try the pach and comment on the Gerrit whether it fits your use-case? And also comment about the options you find useless? (In reply to Mickael Istria from comment #41) > (In reply to bob ross from comment #39) > > Sorry, I did not realize that a patch was already pending. > > Me neither, until a few hours ago ;) > > > The patch that > > you linked to is exactly what I was going to do, although we don't need an > > option to turn off specific characters individually, only an option to turn > > them all off (except for the 'enter' key) > > I agree. > Can you please at least try the pach and comment on the Gerrit whether it > fits your use-case? And also comment about the options you find useless? Any idea when the patch will be merged? I've sent a personal email to Timo and he said he won't modify his patch because he's busy with other things. Still, it was submitted under EPL back then. I guess we can modify his patch and then ask him to just sign the ECA and vote on the Gerrit review when we're ready to merge it. @Bob: do you think you'll have the opportunity to process the comments I've put on the Gerrit review and submit a new patch with those fixed? I'm taking this one. I'll rework Timo's patch and push a fresher version, then ask for review and ask Timo's for IP approval. Looking at all comments and all duplicate bugs, it seems like the use-case is much more precise and specific than allowing to configure the auto insertion trigger chars. The use-case is that for people who have configured more completion proposals trigger chars, they basically don't want trigger chars. I've rephrased the bug title accordingly. The issue here goes beyond just JDT and questions the relevancy of auto-activation on about any character vs completion trigger chars in general and in any editor. I think a part of the solution should be implemented in JFace for more reusability: bug 539165 should provide the behavior and API to ignore completion trigger char (it's actually almost trivial to add it in ContentAssistant and family), then JDT should reuse this API and configure its content assistant according to a preference (trivial-ish too). New Gerrit change created: https://git.eclipse.org/r/129618 *** Bug 534648 has been marked as a duplicate of this bug. *** *** Bug 250784 has been marked as a duplicate of this bug. *** Gerrit change https://git.eclipse.org/r/129618 was merged to [master]. Commit: http://git.eclipse.org/c/jdt/eclipse.jdt.ui.git/commit/?id=0b7dfe14f86da01c63a736d7a22858b078fe1e8c (In reply to Eclipse Genie from comment #50) > Gerrit change https://git.eclipse.org/r/129618 was merged to [master]. > Commit: > http://git.eclipse.org/c/jdt/eclipse.jdt.ui.git/commit/?id=0b7dfe14f86da01c63a736d7a22858b078fe1e8c Thanks, Mickael. I have added a mnemonic for the new option and updated the Javadoc with: http://git.eclipse.org/c/jdt/eclipse.jdt.ui.git/commit/?id=823ad86091f1dcb34ebaf38ab31c43208aff8d62 Please update the following: - Update the F1 help document at org.eclipse.jdt.doc.user/reference/preferences/java/editor/ref-preferences-content-assist.htm. - Add an N&N entry for 4.10. (In reply to Noopur Gupta from comment #51) > - Add an N&N entry for 4.10. Please add a link to it in this bug. New Gerrit change created: https://git.eclipse.org/r/132278 New Gerrit change created: https://git.eclipse.org/r/132280 Gerrit change https://git.eclipse.org/r/132278 was merged to [master]. Commit: http://git.eclipse.org/c/platform/eclipse.platform.common.git/commit/?id=f12e79ab6f5cf397534d034eb597820985321d74 (In reply to Eclipse Genie from comment #55) > Gerrit change https://git.eclipse.org/r/132278 was merged to [master]. > Commit: > http://git.eclipse.org/c/platform/eclipse.platform.common.git/commit/?id=f12e79ab6f5cf397534d034eb597820985321d74 Released the F1 help documentation and updated it with: http://git.eclipse.org/c/platform/eclipse.platform.common.git/commit/?id=6e1fa4793d85e65cfec76054a1a4672545c9ee98 Gerrit change https://git.eclipse.org/r/132280 was merged to [master]. Commit: http://git.eclipse.org/c/www.eclipse.org/eclipse/news.git/commit/?id=8e21d593b0c73ddc4bf2367805e7715f1e6223a2 Verified as fixed in I20181120-1800. |