Menu

#1487 [Feature request] Folding as a block

Won't_Implement
open
nobody
4
2023-07-26
2023-06-06
No

I wish to advance a proposal of improvement. Its about how folding behaves when cut, copy and pasting and when drag 'n dropping.
If a section is folded into one line and the user select that line and copies and pastes or tries to drag’n drop elsewhere, not the whole folded section is processed but only the selected line so it is the first row that folded section starts with.

My proposal is that when a section is folded must act as a block and the user that cut/copy paste or moves with drag’n drop it elsewhere the whole section has to be processed so moved, as happens with Microsoft Word while moving the whole chapter of a structured text.

At the moment if the user wants to process the whole section that is folded has to select the whole section plus one line more. The problem is that not every time it is present an empty line after the section so cannot be done easily.

How to reproduce the bad behavior:
Make a generic content that is possible to fold and fold it clicking on the -+ (folding point): the section folds… than select the row and cut|copy/past or drag’n drop it elsewhere: only the first row is processed if you don’t select an empty row after the folded section.
If you have other text after the folded section that you target for processing you cannot select it correctly.

Also when a section is folded and you try to move it up and down by using the keyboard (Ctrl+Shift+up|down arrow) is expected that the whole section moves before or after the previous or next folded section at once. But instead is un-folded and moves line by line. This too is an ugly behavior (why having folding if the folded sections doesn't behave as a block?) that IMHO needs correction making a folded section move all at once and jump the others folded section all at once too. each folded section has to act as a block since it is folded.

Operating as it is now the risk is indeed to let in the previous position orphan rows.

Thank you for comprehension.

Related

Bugs: #2388

Discussion

  • Neil Hodgson

    Neil Hodgson - 2023-06-07
    • labels: folding, block --> folding, block, scintilla
    • Priority: 5 --> 4
     
  • Neil Hodgson

    Neil Hodgson - 2023-06-07

    Many operations work on the selection, and they operate on just the selection. This request wants to change this to perform operations on a transformation of the selection. I think this will be confusing both for users and developers.

    An alternative may be to make it simpler to select a folded block. This could be implemented by applications with an 'expand selection to block' command or some other mechanism.

     
  • wonka willas

    wonka willas - 2023-06-10

    I think this will be confusing both for users and developers.

    In MS Word or LibreOffice Write or other software such a feature is already present and it is not confusing at all it is a real must have: suppose for ex. that you need to move a complete and long structure made of html tags elsewhere: you compress/fold the structures to the level you need and than you select just a line of code (that action will select everything folded inside it) and move it from the point it is now to where you really need it in just an instant, instead of having to scroll/select maybe hundreds of lines of structured code in a very long document. This feature is even present in Google Chrome dev tools as you can move around a branch of the code tree while it is compressed/folded with no worries, It is not confusing it is a real benediction... In Word and Write you can move a complex structure of complex documents in this way changing the order of chapters and sub chapters for instance making easier organize a complex book in an instant.
    IMHO it is a must have even in Scintilla and Notepad++ as well because sometimes they are used to edit complex structured code files.

     
    👍
    1

    Last edit: wonka willas 2023-06-10
  • wonka willas

    wonka willas - 2023-06-13

    Try LibreOffice Writer is implemented in a sligtly different way.
    Try this:
    create a text and set on it some titles and sub-titles, and also a normal text level as if you where writing a structured book, with chapters and sub-chapters. To be quick for this example use the predefined title styles.
    Than open the navigator (F5 or Writer menu View > Navigator (the icon is a compass)) and you have among other things the structured text with their titles which can be moved by clicking on the Vertical double arrows you can see into the Writer Navigator GUI itself
    The attached video shows it:
    Hope it helps

     

    Last edit: wonka willas 2023-06-13
  • Neil Hodgson

    Neil Hodgson - 2023-06-13

    Than open the navigator

    That is a completely separate user interface outside of the edit pane. Its equivalent to the side-bars commonly implemented by editor applications that use Scintilla for their edit panes. How selection is handled in a side-bar doesn't affect the main editing pane. This desired feature tries to overload the meaning of selection in the main editing pane. The LibreOffice Writer behaviour does not appear to be applicable.

     
  • rdipardo

    rdipardo - 2023-06-14

    If a section is folded into one line and the user select that line and copies and pastes or tries to drag’n drop elsewhere, not the whole folded section is processed but only the selected line so it is the first row that folded section starts with.

    The application (or a plugin) can implement logic to measure the start and end position of the folded region, then pass those values to SCI_SETSELECTION. The resulting selection can then be copied, cut or pasted in its entirety, whether folded or not.

    1. Folded XML element is selected

    sci-setselection-folded

    2. Still-folded selection is placed in the clipboard

    sci-cut-folded

    3. Entire selection is pasted from the clipboard

    paste-from-clipboard

     
    🎉
    1
    • johnsonj

      johnsonj - 2023-06-15

      What a good idea!
      How can you do that?

       
      • rdipardo

        rdipardo - 2023-06-18

        How can you do that?

        One approach could involve a hook for the SCN_DOUBLECLICK notification that checks if the SC_FOLDLEVELHEADERFLAG bit has been set on the affected line. If so, the hook can search forward to learn the position of the corresponding line where the fold level drops again.

        The particular application can work this out with Scintilla's existing APIs — and that's the point.

        This feature request originated on the Notepad++ community forum, where it properly belongs. I suggest closing this ticket as invalid, or, at most, as an existing capability.

         
  • Neil Hodgson

    Neil Hodgson - 2023-06-18
    • Group: Initial --> Won't_Implement
     
  • Neil Hodgson

    Neil Hodgson - 2023-06-18

    Marking as "Won't Implement" as it appears that the main idea can be implemented by application logic. Will close after a while if there is no further discussion.

     
  • wonka willas

    wonka willas - 2023-06-22

    Scintilla with its folding feature basically tries to emulate a tree view, kind of... When a branch of a tree is moved with drag-n'drop or by copy-paste it is moved entirely with all its children until next sibling. An example should be even MS Word (ver2016) in both Structure view and Page Layout view. Here some screen recordings of an excellent behavior of this amazing and useful feature to obtain the following results I just have to turn into chapter or tiles or headers a row of the text in Word. This is what is possible in Page layout view and Structure view, which behaves optimally and would be great to have a similar thing into Scintilla too to move html xml or other folded branches at once with children:

     
    • wonka willas

      wonka willas - 2023-06-22

      I don't think its implementation would be very difficult because the basics are already present so there are just some fine tune to do to make it a complete feature.

       

      Last edit: wonka willas 2023-08-05
  • Vic

    Vic - 2023-07-26

    As a simple editor user, I think such features would be very useful, whether they are done in Scintilla or in editors.

    Perhaps it's possible to meet half way, and just have Scintilla expose some parameters or procedure that would make it easier to implement this feature in application?
    Refering to what @Robert wrote above:

    The application (or a plugin) can implement logic to measure the start and end position of the folded region, then pass those values to SCI_SETSELECTION.

    Could it be that this would be more efficient to be implemented in Scintila, maybe as a method (I'm not sure on tech. details), that given current position as input, it computes the start and end positions of the fold region that that belongs to the line where this position is in ?

    (I don't know how scintilla works, maybe all those positions, for all folds, are already computed and stored for the entire session)

    If it makes sense at all.

     

    Last edit: Vic 2023-07-26

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.