Registered Member
|
Hi all,
I'm really enjoying KDevelop, but coming from the Eclipse IDE I noted that auto-brackets function is not so smart: I mean each time I open a bracket the editor places a closing one, even if the closing one is already there. For instance:
that is missing an opening bracket, so when I add a new one I end up with the following code:
and a similar behavior is there for quoting, so that if you open a tick the closing one will be placed on the same line, so that I often end up with multiple ticks. Am I missing some trick in the configuration or this is the default KDevelop behavior? |
Global Moderator
|
I can confirm that I was annoyed by this a few times already, and that I effectively don't use auto brackets because of such issues (KDevelop itself does some auto-bracketing too, like for calling functions, the behaviour is more intelligent there).
To add an issue to the list: I think the correct behaviour to auto-add curly braces is this: if the user types "{", do nothing. As soon as "Enter" is pressed, switch to the next line, indent, and add a dedented "}" in the line below in case the document has mismatched "{"s overall. This whole problem, however, is only related to kate (not in the scope of KDevelop). It must thus be improved there. I think it would definitely be worth it. I think the relevant code is in kate/part/plugins/autobrace/autobrace.cpp. Greetings
I'm working on the KDevelop IDE.
|
Registered Member
|
This is exactly the behavior of Eclipse. [quote="scummos"] This whole problem, however, is only related to kate (not in the scope of KDevelop). It must thus be improved there. I think it would definitely be worth it. I think the relevant code is in kate/part/plugins/autobrace/autobrace.cpp. [quote] Interesting, I'm going to have a look at the source code, I'm curious. |
Global Moderator
|
Yes, and the only sane one.
Cool, good luck
I'm working on the KDevelop IDE.
|
Registered Member
|
I took a look at the autobrackets.cpp source code, and it seems that it already implements the right behavior. I'm testing it right now.
|
KDE Developer
|
Afaik the "autobrace" plugin (configure editor -> extensions) is also better in handling such cases, try it out.
current KDE projects: Quanta, KDevelop, Kate
|
Global Moderator
|
Judging from the name, that also seems to be the one related to the source code I found. Is there more than one engine doing this?
I'm working on the KDevelop IDE.
|
KDE Developer
|
afaiks there is kate built-in stuff that handles this not-so-well and the plugin which is somewhat better - but not sure whether that has changed since I last hacked on the plugin
current KDE projects: Quanta, KDevelop, Kate
|
Registered Member
|
This is actually more work if you're modifying existing code, IMO. Let's say that you have some existing code that you want to wrap with an if statement, because it's executing when it shouldn't. If you type the following and press enter, KDevelop is going to add two lines that you'll have to delete.
What I do when adding new code is to type if( cond ) {} , left arrow, enter: I hold down shift while pressing the adjacent { and } keys, move the cursor inside them, and press enter. Kate and KDevelop both place the cursor on the next line, indented, with the curly brace unindented on the line after that. |
Global Moderator
|
In my opinion the correct solution to solve this problem is to make the user edit and the IDE addition (auto bracket and newline) two seperate edits which can be seperately undone. The you can just do what you want and press Ctrl+Z in case you want to remove the auto-brackets. Do you think that would work okay?
I'm working on the KDevelop IDE.
|
Registered Member
|
Yes, that would work fine for me. It wouldn't hurt to have an option somewhere to disable auto-bracket; I've heard rants from people who couldn't stand the fact that some software system insisted on doing something that (in their opinion) rarely or never helped them. |
Global Moderator
|
You can easily disable auto-brackets in the settings. I'm using this option...
I'm working on the KDevelop IDE.
|
Registered users: Bing [Bot], claydoh, Google [Bot], rblackwell