WIP DocumentPrivate: Remove all from next line which may annoying when joining lines
Needs RevisionPublic

Authored by loh.tar on Nov 23 2018, 11:00 PM.

Details

Reviewers
cullmann
mwolff
Group Reviewers
KTextEditor
Summary

Diff Detail

Lint
Lint Skipped
Unit
Unit Tests Skipped
loh.tar created this revision.Nov 23 2018, 11:00 PM
Restricted Application added projects: Kate, Frameworks. · View Herald TranscriptNov 23 2018, 11:00 PM
Restricted Application added subscribers: kde-frameworks-devel, kwrite-devel. · View Herald Transcript
loh.tar requested review of this revision.Nov 23 2018, 11:00 PM

This works so far in most cases I have tried.

  • C/C++, // and /* */ works, but sadly not Oxygen style comments. Guess the single star is not as special marked. Could that be fixed in the highlight stuff?
  • Bash, # works
  • Ruby, # works
  • Python, # works
  • PHP, // works, # works NOT which surprised me because they are as comment colored
  • Tcl, # works, backslash comment continuation works not but it's not surprising

Whereas I think such an extension is good, I am not sure if the normal join lines should try to be that clever.
ATM it is very "deterministic" what happens and I think people like that.
It would make more sense to have an extra action for such a "smart" variant in my eyes.
What do others think?

loh.tar added a comment.EditedNov 25 2018, 9:16 AM

I am not sure if the normal join lines should try to be that clever.

But consider the "auto comment" feature after you hit "Return", it's also somehow "special clever" but very useful. This tries to add the corresponding functionality. Well, the true opposite would be when you hit "Del" at the on of a line. Yeah, sounds good, will look at that too but it is (almost, see next note) independent from this aim.

I'm currently digging into the wrap functionally which is broken since a decade BUG135737. Sometimes it works already pretty well (with normal text) but sometimes it drives nuts (without selection in a code file). Very strange. Why I mention this? There I have follow a suggestion posted in that bug report, just o trigger a "Return" input at the right place. Now, while writing this text I came up with this "Del" idea. So, it may a good idea to re-design this patch (?)

It would make more sense to have an extra action for such a "smart" variant in my eyes.

An extra action looks to me at first sight a little overdone, but an option how join behaves may appropriate. Let me know where to place that in the Edit Options page if you (and other) like that idea

Edit: Um, stupid me, these "auto comment" works only in Qxygen style.

However. At the end I like to have it also for double slash comments, quotations > and such. Working like Nano editor reformat a quotation paragraph

An extra action looks to me at first sight a little overdone, but an option how join behaves may appropriate.

An option in the settings would work for me, too.
I just don't want to destroy the work-flow of people that rely on the current behavior.

As background: inserting the '*' automatically is done by the indenter in cstyle.js. Theorwtically, we could even add a joinLines function to the indenters as well and call it if it exists, and if not use the default implementation. Just an idea... Usually, the motivation for moving something into an indenter boils down to whether a specific behavior is related only to a specific programming language, i.e. when a general purpose solution cannot be done.

Thanks for your input Dominik.
In the meanwhile I noticed (again) these "Smart-Return" function (I noticed, and used that a couple of years for a short time period, but forgot that somehow) A reverse version of that should be nice. And somehow the possibility to use that automatically without to todo some special key-stroke when join lines by simple remove the newline character by Del-Key.

But how that all could be done in sane way I have no idea. Currently I tend to make a new "Smart-Wrap-Paragraph" function, as suggested by Christoph. Because that's new, I can try to be as smart as I like without to change old behaviour.

As said is from my point of view the existing wrap function broken, not only due to the behavior described in that bug report 135737 but also because the whole file is wrapped when no selection is done. That's not handy. This way you can't wrap quickly only a paragraph by shortcut without to select them previous. I have often scrambled a code file when I only want to warp some comment block.

I think we could do that in two steps:

  1. Introduce some "smart wrap" setting and using generic code like the above for that
  2. If then still we have too many issues, one could outsource that to a js function (if there, like Dominik proposed).
cullmann requested changes to this revision.Dec 26 2018, 9:54 PM

As said above, I think some "smart wrap" option and that can be used for it.

This revision now requires changes to proceed.Dec 26 2018, 9:54 PM
loh.tar updated this revision to Diff 48486.Jan 1 2019, 6:09 PM
loh.tar retitled this revision from DocumentPrivate: Remove comment mark when joining lines to WIP DocumentPrivate: Remove all from next line which may annoying when joining lines.
loh.tar edited the summary of this revision. (Show Details)
  • Don't rely on comments or highlighting

This way you can also handy join e-mail like quotations.

It's almost untested, will try to use it on daily basis.
After think a little about it, I came to this variant. Code lines are unlikely to "join", so why test for comments?

A little off topic: Would it OK to modify the wrap stuff that it behaves differently? There are some bug reports and comments which often says, "nope".

I have in mind that without a selection only the current line is wrapped and not the whole document.

loh.tar updated this revision to Diff 48994.Jan 8 2019, 3:19 PM
loh.tar set the repository for this revision to R39 KTextEditor.

Try to be smart

loh.tar added inline comments.Jan 8 2019, 3:26 PM
src/document/katedocument.cpp
4016 ↗(On Diff #46095)

Can one point me why this is needed/desired? I'm often annoyed from the keeped space

mwolff requested changes to this revision.Jan 15 2019, 1:38 PM
mwolff added a subscriber: mwolff.

can you please rephrase the title of this review to make it understandable? "Remove all" - what do you remove? All what?

Also, can you please add tests for the feature you are adding, this also acts as documentation on what this patch actually does

This revision now requires changes to proceed.Jan 15 2019, 1:38 PM

can you please rephrase the title of this review to make it understandable?

Of course, if I could, I would have done it :-) "Remove all what is not nice text" ? It may help you to read all posts to get a hint of my intention.
It turned out that this here ist still not working charming. Sometimes is still stuff removed which shouldn't.