Bug 308614 - Auto brackets should be smarter (e.g. take context into account)
Summary: Auto brackets should be smarter (e.g. take context into account)
Status: RESOLVED FIXED
Alias: None
Product: frameworks-ktexteditor
Classification: Frameworks and Libraries
Component: general (show other bugs)
Version: unspecified
Platform: Gentoo Packages Linux
: NOR wishlist
Target Milestone: ---
Assignee: KWrite Developers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-10-18 18:46 UTC by Manuel Nickschas
Modified: 2015-10-11 12:29 UTC (History)
3 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Manuel Nickschas 2012-10-18 18:46:34 UTC
I switched (back) to KDevelop from Qt Creator, and while I find that KDevelop's editor is much nicer, and the auto completion in general much smarter, there is one issue that is really annoying:

The "auto bracket" feature does not take context into account at all. This means

1) The closing bracket is always added regardless if there is a matching number of opening brackets. This often leads to superfluous closing parens, especially visible when auto-completing connect() calls. This is also annoying when editing existing code where the closing bracket is already in place. Another occurance is quotes - often when editing strings, I will remove the opening quote while the end of the string with the closing quote is still in place, and KDevelop unhappily adds another pair of quotes.

2) When deleting code inside a pair of brackets, the closing bracket is removed too even though the matching opening one is still there.

3) Often when typing fast, I type a closing bracket automatically. While not technically a bug, it would be a nice feature to "ignore" that extra bracket in these cases. Qt Creator does it this way (if you type the closing bracket right after it had already been auto-completed, it won't add another one) and it really helps.

4) There should be no autocompletion of apostrophes inside comment blocks. After all, the apostrophe in English text usually shows up as a single :)


Reproducible: Always

Steps to Reproduce:
Enable general auto completion and "Auto Brackets" and start coding. Try things like connect() calls (with auto-completion of SIGNAL and SLOT) and see how you get superfluous closing characters...
Actual Results:  
See above.

Expected Results:  
I think the overall experience could be improved drastically with the following improvements:

1) Always try to match the number of open parens/brackets/quotes/whatever when autocompleting. Don't add more than necessary.
2) Ignore a typed paren/bracket/quote/whatever if the same character has just been autocompleted and there's no matching open character
3) Don't autocomplete apostrophes in comment blocks
4) Just look at how Qt Creator handles it, it proved to be an almost perfect experience for me
Comment 1 Christoph Cullmann 2015-10-08 11:22:27 UTC
All valid improvements wishs, somebody up to create a patch? Basic brackets adding is back in ktexteditor master.
Comment 2 Sven Brauch 2015-10-11 12:29:17 UTC
I think I added most of this to Christoph's basic implementation in master/KF5. Try it out and let us know if you're still missing something.