I understand the built in autobracket feature was removed from kate - I am not happy about this as the plugin lacks important functionality. Reproducible: Always Steps to Reproduce: 1. select some text and press ", (, { or [ 2. 3. Actual Results: kate removes the text and replaces it with the pressed character Expected Results: kate should enclose the selection in "", (), {} or [] respectively.
It gets worse... The plugin only produces a closing bracket on return - which is useless on one liners. It sometimes removes a closing character when it shouldn't and places closing characters when it shouldn't.
Same issue(s) here using 4.10rc3
I confirm this regression. Just one question: why the existing feature has been removed and replaced with an incomplete one? Thanks for the attention.
Anyone interested in sending a patch? The relevant code that was removed can be found in katedocument.cpp in: https://projects.kde.org/projects/kde/kde-baseapps/kate/repository/revisions/d51d4820a854985a833f28f1facac9d9287466ab It needs to be added to the autobrace-plugin. Just follow http://kate-editor.org/get-it/ and edit the files in part/plugins/autobrace. Would be really cool to get a patch!
I hoped this is going to be resolved after rc3 but could not wait longer. After looking at the new autobrace plugin and decided it was beyond me patch it I managed to write a new plugin implementing the old functionality bar the deletion which I found to be an annoyance too often. I hope people will share my experience but I can put it in as default option. A configuration panel will have to be made in this case. The tutorial at http://techbase.kde.org/Development/Tutorials/Kate/KTextEditor_Plugins was helpful as well as the autobrace plugin itself. By the way https://bugs.kde.org/show_bug.cgi?id=314325 is duplicate of this but I cannot mark it as such.
Created attachment 77176 [details] autobrace plugin rewrite
*** Bug 314325 has been marked as a duplicate of this bug. ***
Ok downloaded and built... So far seems to work as advertised. I should know in a day or two if this will stand up in a production environment.
Nice, any chances that it could be included in future release? Although there is small but annoying issue, it adds one useless action to undo history (I've checked behavior of Kate in KDE 4.8 and it works correctly).
Yes indeed it adds annoying extra undo step because the signal of the edit gets to the plugin after the text has been changed i.e. the opening character typed and selection deleted. The KTextEditor::Document class does not provide 'undo'. It is only given in KateDocument and I am not sure whether I can use it in a plugin. I am trying to remember whether the undo issue existed in 4.9 but I can't. In 4.8 I think the autobrace might have been an internal KateDocument feature.
(In reply to comment #10) > I am trying to remember whether the undo issue existed in 4.9 but I can't. I don't have 4.9 available right now, but I don't remember such issue (although undoing after such action is not something that is done very often).
Works for me well. Only problem was that the installation copied the files in the wrong paths(?), so I had to copy them myself to the proper ones. sudo cp /usr/local/lib/kde4/ktexteditor_bracesane.so /usr/lib/kde4/ sudo cp -r /usr/local/share/apps/ktexteditor_bracesane/ /usr/share/apps/ sudo cp -r /usr/local/share/kde4/services/ktexteditor_bracesane.desktop /usr/share/kde4/services/
(In reply to comment #12) > Only problem was that the installation copied the files in the wrong > paths(?), so I had to copy them myself to the proper ones. You should use correct prefix, like: cmake ../ -DCMAKE_INSTALL_PREFIX=`kde4-config --prefix`
I think I have fixed the undo issue. I noticed the history entry is recorded after the textRemoved and textInserted signals and before the textChanged signal.
Created attachment 77216 [details] autobrace plugin rewrite - fixed undo
(In reply to comment #14) > I think I have fixed the undo issue. Confirmed, works fine now. But compiler now issues two warnings about unused parameter ‘document’.
> But compiler now issues two warnings about unused parameter ‘document’. These are OK as they are send from the signals. I'll disable the warnings to not raise suspicion.
Created attachment 77220 [details] autobrace plugin rewrite - fixed undo - no ununised parameter warnings
(In reply to comment #17) > > But compiler now issues two warnings about unused parameter ‘document’. > These are OK as they are send from the signals. I'll disable the warnings to > not raise suspicion. Sure, but it looks better without any warnings. ;-) AFAIK you could just omit unused variable in method signature and create connection like: connect(document, SIGNAL(textChanged(KTextEditor::Document*)), this, SLOT(slotTextChanged()));
There seems to be some issues with this extensions, like additional brackets while pasting snippets. For example pasting contents of this one to empty document: http://paste.kde.org/669770/ Creates additional closing curly bracket at end. And even weirder one, selecting contents of above file and pasting gives very weird results. Both happen only while extension is enabled. Is it possible to detect text pasting and exclude such cases?
Created attachment 77225 [details] autobrace plugin rewrite - fixed paste It seems there is no sane way to distinguish, in a plugin, between pasted and typed text. I fixed the pasting issue you experienced and I think the only time a closing character will appear after a paste operation will be if the pasted text consists of a sole opening character. There is no way to prevent this AFAIK. Thanks for the slot tip. I can see how it may work for singe argument (or rather last argument), but I am suspicious about the case of slotTextRemoved where the second arg is important but the first unused. I put the Q_UNUSED(arg) macro to deal with this.
Confirmed, seems to work flawlessly now. :-) (In reply to comment #21) > Thanks for the slot tip. I can see how it may work for singe argument (or > rather last argument), but I am suspicious about the case of slotTextRemoved > where the second arg is important but the first unused. I put the > Q_UNUSED(arg) macro to deal with this. AFAIK Q_UNUSED() is the only solution in such case.
Created attachment 77269 [details] autobrace plugin rewrite - fixed paste in block mode I have found and fixed what I hope is the last issue with this plugin: pasting text in block mode with sole opening character in the first line lead to erroneous closing chars being added.
There is one minor detail still missing, Kate used to remove closing character when opening one was deleted (tested using KDE 4.8). For example if we deleted "(" from "function()" then ")" was also deleted.
Hi Michał, I mentioned in my first post that I did not implement this one feature. After many years with it I found it counterproductive. Though If you and others like it I can implement it and put an option for disabling.
Oops, I've overlooked that. And yes, surely it could be annoying for some users so if it would be added then maybe it would a good idea to make it optional (disabled by default).
I also vote for having back the automatic deletion of the closing parenthesis/quotes. I would like to report that the plugin has a problem when the text selection starts at the end of a line. Thanks for the plugin Dimitar, in my office everyone was missing this functionality.
I agree about a setting to enable/disable the automatic deletion of the closing char. Thanks!
Created attachment 77378 [details] autobrace plugin rewrite - remove closing option by default Yes indeed when the selection starts at end of line it gets messed up. This attachment fixes this and adds an option to enable/disable removing of the closing character if the opening is deleted as a sole character. If the removal is part of a selection then the closing character is restored.
Thanks a lot. :-)
Just found one more bug :) I have the following text and I want to replace all occurrences of ' with ' location=grep '<name>' | sed -e 's/<name>\(.*\)<\/name>/\1/' country=grep '<country>' | sed -e 's/<country>\(.*\)<\/country>/\1/' When I launch the replace all command I get this: location=grep '''<name>'| sed -e 's/<name>\(.*\)<\/name>/\1/' country=grep '<country>' | sed -e 's/<country>\(.*\)<\/country>/\1/' instead of this that I should get: location=grep '<name>'| sed -e 's/<name>\(.*\)<\/name>/\1/' country=grep '<country>' | sed -e 's/<country>\(.*\)<\/country>/\1/' The same of course occurs if you want to replace all with ", (, { and anything else the plugin will autobrace.
*** Bug 315389 has been marked as a duplicate of this bug. ***
I have looked a bit this evening and I did not see how to get a signal for beginning of search&replace action in a sane way. As it is now I cannot differentiate between the different kinds of replace: type over selection, paste over selection and search&replace. The way the remove insert and change signals are sent is bad enough in that it requires significantly messier code, to somewhat distinguish between the first 2, than I wish to have. If anyone has an idea how to fix the search&replace issue I will be glad to hear it! Otherwise I hope this plugin is a short term solution until the original feature is brought back. When I wrote the first version I had no patience left and thought this should be simple thing. After figuring out the quirks of ktextdocument it does look like a plugin is the wrong approach for this functionality.
BraceSane works fine, thank you! But it still makes me wonder. What was the reason to remove the functionality from Kate in the first place? Why was AutoBrace used as a replacement if its author never intended it as such (as he told me in an email)? Has the KDE dev team gone totally insane?!?!
Of course we are insane, mad, totally crazy and what not at the same time. What did you expect? On a more serious note: It was removed because it clashed with the shipped autobrace plugin and thought the autobrace plugin would work just fine. It's that simple. If we add the feature back, the autobrace plugin won't work correctly anymore. I think we should bring the option it back, along with the possibility that the auto-bracket option is handled by indenters as it is sometimes language-specific...
Tommi, I said "originally", not "never". Please don't twist my words and don't resort to name calling, it's not very productive. The Kate team has improved the functionality a lot and is clearly working on getting the best of both worlds out to the people. On that note, let me also say that I find it heartwarming how all of you guys work together to make my originally sidelined plugin really awesome and versatile. Here's a huge thanks for everyone involved.
Dominik: Sorry for the strong words but they came from the heart: lost functionality seems to be the ongoing trend now in KDE (as it is in G****). The AutoBrace plugin is a poor substitute, if only because braces {} are only completed for LaTeX files. I write most of my scripts and programs in Python and need all of () [] {} "". Jakob: I misunderstood you then. However, I fail to see the difference between “originally” and “never” if we are talking about the timeframe when you created the plugin. Also I find it strange that no one seems to have bothered to check whether the plugin really did the job of the old feature before deciding to remove the feature.
I would like to add the plugin design for single and double quotation marks is different from the original builtin function. The builtin function did not add a closing single or double quotation mark when the opening mark immediately follows a non space character. The original builtin function added the closing quotation mark only when the opening mark followed a space, which is appropriate behavior. I confirm the behavior with braces {}. I see the reasoning for adding the closing brace with pressing Enter, useful in a programming environment, but confusing to anybody wanting to use braces in a single line. Thanks. :)
Thank you for this plugin! This is one fuctionality I was missing in kdevelop, the one that ships kind of sucks. Cheers!
@Dimitar thanks for your plugin, I found a bug, in a function, if I add a "if(statement)" and press return, and then try to add the curly braces, then it only add the closing one. For instance, I get: void function() { if(blah) } } It seems to be caused by the automatic indentation being removed. I have fixed the problem in the plugin, by commenting in the function "BraceSanePluginDocument::slotTextInserted", the second if case: else if (op_inserted && inserts == 1) { ... } (which seems to be related to the paste bug, but even with that code commented, I could not reproduce the paste bug).
how about something like this?? diff --git a/addons/ktexteditor/autobrace/autobrace.cpp b/addons/ktexteditor/autobrac index ac079b6..ed7b303 100644 --- a/addons/ktexteditor/autobrace/autobrace.cpp +++ b/addons/ktexteditor/autobrace/autobrace.cpp @@ -267,7 +262,11 @@ void AutoBracePluginDocument::slotTextInserted(KTextEditor::Docu // Only insert auto closing brackets if current text range // is followed by one of the allowed next tokens. if (allowedNextToken.contains(nextToken(document,range))) { - insertAutoBracket(document, range, brackets[text]); + if (view->selection()) { + insertAutoBracket(document, range, brackets[text] + view->selectionT + } else { + insertAutoBracket(document, range, brackets[text]); + } } }
my terminal was not wide enough when I copy/pasted s/view->selectionT$/view->selectionText());/
Also, pressing { used to yield {} (which was good) whereas now it requires a new line before producing the } (which is bad). Also (which was good), with [x] and the cursor after the x, two back spaces would remove all three chars, now (which is bad) the ] is left behind. Also, would like to add my voice to the frustration expressed about losing the ability to highlight and surround with "", '', {}, [] and ()
Can anyone tell that what is finally to be done in this bug so that it can be closed?
It seems that this persists in the Qt5 version of Kate (which has no autobracket plugin)
Everything works fine for me. Can anyone tell what left in this bug?
(In reply to sahil from comment #46) > Everything works fine for me. Can anyone tell what left in this bug? Everything this bug describes is still not working as far as I can tell.
Massimiliano Torromeo is correct, I think. I still see all the same behaviour (with Tools.Mode.Normal, if that`s relevant) that is described in Comment 43.
KTextEditor master has now at least a partial implementation back, for the commits look in bug 350317
I added some features as well in master/KF5, I'll close this; please re-open if you're still missing something.
Created attachment 94970 [details] attachment-2623-0.html Thanks. Guess I'll have to wait for it to go through the release process before I can tell (I use Kubuntu). Not actually sure how I'll know when your changes have made it too my machine! Cheers Rik On 11 October 2015 at 13:27, Sven Brauch <mail@svenbrauch.de> wrote: > https://bugs.kde.org/show_bug.cgi?id=313455 > > Sven Brauch <mail@svenbrauch.de> changed: > > What |Removed |Added > > ---------------------------------------------------------------------------- > Resolution|--- |FIXED > Status|CONFIRMED |RESOLVED > CC| |mail@svenbrauch.de > > --- Comment #50 from Sven Brauch <mail@svenbrauch.de> --- > I added some features as well in master/KF5, I'll close this; please > re-open if > you're still missing something. > > -- > You are receiving this mail because: > You are on the CC list for the bug. >
I am using the latest available kate, 15.08.2 any idea in which release the new changes will be available? thanks
The next one.