Recent

Author Topic: Unfolding bug after searching  (Read 5787 times)

Muso

  • Sr. Member
  • ****
  • Posts: 356
Unfolding bug after searching
« on: April 20, 2021, 03:20:59 am »
I noticed the following bug on unfolding a section:

- press Shit+Alt+0 to fold everything
- search for a procedure name
- try to unfold the found procedure

result: it is not unfolded but disappears, see the attached screencast.

Lazarus 2.1.0 r65025 FPC 3.2.0 x86_64-win64-win32/win64
« Last Edit: April 21, 2021, 07:25:03 pm by Muso »

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 9755
  • Debugger - SynEdit - and more
    • wiki
Re: Unfolding bug after searching
« Reply #1 on: April 20, 2021, 04:29:28 am »
Actually not a bug. But maybe an unexpected side effect of a feature.

Lets have a look.

1) Folding vs Hiding
- Folding means the first line stays visible
- Hiding ( lines with // comments at the start of line)
   Means the line gets hidden

Hidden lines have the unfold symbol on the line above (unfold is a down-arrow).
Also the "hide me" symbol is a "dot" not a "-"

2) You can hide any lines you want by selecting them.
The current selection automatically adds a "hide me" to the gutter.

3) When you search for the procedure name, it becomes selected.....

Well and as you can see in your image, the symbol at the start of that line changes.
And if you click it, the line gets hidden. The "unhide" symbol appears above.

So that is what happens...


The problem is that in any line there can be more than one actions (fold,hide,unfold).
And also more than one block to fold
Code: Pascal  [Select][+][-]
  1. if a then begin if b then begin
has 2 blocks opening. The gutter symbol gives access to the inner/last "begin" block.

Right click on the gutter (the thin part of the gutter with the fold symbols) will give you access to all the blocks.

Muso

  • Sr. Member
  • ****
  • Posts: 356
Re: Unfolding bug after searching
« Reply #2 on: April 20, 2021, 10:56:12 am »
Well and as you can see in your image, the symbol at the start of that line changes.

Thanks for the explanation.

As you can see in my screencast, all other procedures are folded and get the + button to unfold it. So why is the + button changed just because I found the procedure of interest by searching and not by just looking with my eyes?

I understand now that the feature is to provide hiding when a line is selected. But this should not be the case when selected by a search result.
I argue because the typical uses case is that you have tons of procedures and need to have the overview and to search/find the procedure of interest.

Therefore I would be happy if you could consider of adapting the hiding/folding feature a bit.

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 9755
  • Debugger - SynEdit - and more
    • wiki
Re: Unfolding bug after searching
« Reply #3 on: April 20, 2021, 02:52:15 pm »
Btw, you can assign (if not set by default) shift-alt + do unfold (and Shift-Alt - to fold).
That will work, even if there is a selection.

provide hiding when a line is selected

When any part of a line is selected.

Quote
As you can see in my screencast, all other procedures are folded and get the + button to unfold it. So why is the + button changed just because I found the procedure of interest by searching and not by just looking with my eyes?
Because it is a selection. It does not matter by what action it come to be selected.

Quote
Therefore I would be happy if you could consider of adapting the hiding/folding feature a bit.

I do agree.

There should at least be an option to disable "hide selection" completely (we got options for all else).

It would also be good, if both (unfold and hide) could be displayed. I am not quite sure yet how.....
(This would not be in all cases witch more that one action, but probably only with opposing actions. expand and collapse)

You can add a feature request on our bugtracker.
I just don't know yet when I will be able to fit it in.

---
There is also  a bug, that somehow prevents the ability to configure the IDE to use shift mouse click to unfold, when the hide icon shows....
Though this config is only avail in the "advanced mouse actions". So it is all, but trivial.

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 9755
  • Debugger - SynEdit - and more
    • wiki
Re: Unfolding bug after searching
« Reply #4 on: April 20, 2021, 04:25:05 pm »
Ok, so I did (partly) fix the advance mouse....

If you want to be able to "shift" or "shift-ctrl" click the "hide selected" icon, and yet have it unfold the line.

This only works, if you use any of the modifier keys (shift and/or ctrl). The editor is not smart enough to detect, if there are both actions. So you need to keep the default "fold" action, or you can't fold by mouse any more.


If you want to go that way.

Apply the patch (or edit the file) and recompile the IDE (the line numbers are trunk/2.1 ; but it should work for 2.0.x too)
https://github.com/User4martin/lazarus/commit/adfff37ad6509bc90c7a3dce4eb42d18b9bdbfb6
https://github.com/User4martin/lazarus/commit/adfff37ad6509bc90c7a3dce4eb42d18b9bdbfb6.diff

See the image on how to configure.
The below assumes you gonna use the shift + ctrl key.


1&2) You need to add an action, for what happens when you click on a "collapse" [ - ] or [ . ] symbol. (Because with the selection you well see the "hide" symbol)

3) There are already various actions.
- The image shows them *after* the change described here.
- To start with they will show a "-" in the shift column. That means those actions will trigger independent of the shift key (with or without shift)

As you gonna add an action that relies on "shift + left mouse", you need to tell all existing actions, that they should not trigger when shift is pressed. Otherwise they would conflict with the new action. (and you would get an error, trying to add the new action).

Note: You only need to look at actions with "up/down" = up. The "down" action, stays as it is.

For each of the existing "up" actions, you need to edit the action. You can do that by double click (or using the "change" button).
Then in the window that opens to edit the action (same window as in step 5, but having the settings for the existing action), clear the checkbox for "shift". That checkbox will be greyed to start with. "greyed" = does not matter. => change it to "unchecked".

4 & 5) Add a new action.
The image shows what settings the action needs.

The green line will be added, when you click ok.

---
After that you can shift+ctrl click the [ . ] symbol, and unfold the code.

You can also assign this to the middle mouse, without any shift. Then you do not need to edit the existing actions.
https://wiki.lazarus.freepascal.org/IDE_Window:_EditorMouseOptionsAdvanced
« Last Edit: April 20, 2021, 04:30:03 pm by Martin_fr »

Muso

  • Sr. Member
  • ****
  • Posts: 356
Re: Unfolding bug after searching
« Reply #5 on: April 20, 2021, 07:35:17 pm »
Ok, so I did (partly) fix the advance mouse....

To be honest, I am an IDE beginner. I code with Pascal for years, but never had the time to dive into the IDE. Now I have a larger project and struggle with basic things. So maybe before you proceed, here is what I would find very useful:

- right-click on the + icon in front of a procedure/function and get in the context menu the option to un/fold all procedures/functions (like already implemented for comments)
- same as above but for all except blocks
- either a menu or a context menu option, to unfold everything to level 0
- the advanced mouse actions should be self-explanatory. because at the moment I don't understand what is e.g. the current shortcut to fold everything.

I updated Lazarus trunk via FCPupDeluxe and now I can no longer fold everything using Shit+Alt+0. So what do I have to use now for this?
I see in the Advanced Mouse options:

Fold Code   Left   Any   Up   -   -   Y   0      All (Nodes)

So I think I have to cleft-click while pressing the Ctrl button and then all nodes will be unfold. But this doesn't work

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 9755
  • Debugger - SynEdit - and more
    • wiki
Re: Unfolding bug after searching
« Reply #6 on: April 20, 2021, 08:21:58 pm »
Ok, so I did (partly) fix the advance mouse....
To be honest, I am an IDE beginner. I code with Pascal for years, but never had the time to dive into the IDE.

Actually I hadn't paid attention that you are using trunk, and that therefore you could just fpdeluxe up to the fixed version...

So you do not need to edit the file (or apply the patch).
If you did have to, it is easy.
- Open the file, edit the one line, as shown on the github page.
- Save the file
- Tools > Options > Build IDE
done.

But anyway, not needed.

Quote
So maybe before you proceed, here is what I would find very useful:

- right-click on the + icon in front of a procedure/function and get in the context menu the option to un/fold all procedures/functions (like already implemented for comments)
- same as above but for all except blocks
Nice ideas, but I have a large todo list, before this.

Quote
- either a menu or a context menu option, to unfold everything to level 0
"to level 0" is just a fancy way to say: unfold all / remove all folds?

If you have folded lines, then the fold gutter context menu has that entry.

Quote
- the advanced mouse actions should be self-explanatory. because at the moment I don't understand what is e.g. the current shortcut to fold everything.
The advanced mouse option, is a bit like Firefox "beware dragons" advanced options.

The normal mouse options, cover more than most people need. But there always had been a few people wanting something different. The advanced options are for this.
(Currently the overall options do not have a way have disabling advanced options, otherwise they would be invisible by default).

They are explained on the wiki. But they are to complex to be intuitive. (In a way they are a basic programming language)

In this case, I gave you the exact setting to apply. => that is to apply blindly, without understanding why. (the why is on the wiki)
 
Quote
I updated Lazarus trunk via FCPupDeluxe and now I can no longer fold everything using Shit+Alt+0. So what do I have to use now for this?
This should still work. Please check your keymap setting, as in the attached image.

Quote
I see in the Advanced Mouse options:

Fold Code   Left   Any   Up   -   -   Y   0      All (Nodes)

So I think I have to cleft-click while pressing the Ctrl button and then all nodes will be unfold. But this doesn't work
I assume that is in the section "collapsed". I.e. applies when you click on a [ + ] symbol

Depends on your reading of "all nodes".
"all nodes" here means: all nodes on this line.
Code: Pascal  [Select][+][-]
  1. if a then begin if b then begin
if both "begin" blocks are folded, you can either
- open one of them
- open both (all)

That does not apply to nodes on other lines.

If you want to, I can give you instructions, how to unfold all nodes on all lines, by clicking on the fold gutter.
(Ideally just clicking on the gutter outside of a [ +- ] symbol. I.e. empty parts of the fold gutter, or vertical line parts. / Or using middle button / Otherwise a lot more editing is needed).

Or send me your editoroptions.xml => and I add the middle click to unfold all, and send it back to you.



« Last Edit: April 20, 2021, 08:29:27 pm by Martin_fr »

Muso

  • Sr. Member
  • ****
  • Posts: 356
Re: Unfolding bug after searching
« Reply #7 on: April 20, 2021, 08:51:28 pm »
Quote
- either a menu or a context menu option, to unfold everything to level 0
"to level 0" is just a fancy way to say: unfold all / remove all folds?

If you have folded lines, then the fold gutter context menu has that entry.

Yes, I meant to completely fold, like using Alt+Shift+1.
I don't see this in the context menu. I right-click onto the + icon in front of a procedure and get the attached.

So when I right-click onto the icon in front of a folded procedure I get a content option to unfold all, but when I right-click onto the icon in front of an unfolded procedure I get no context option to fold all.

Quote
They are explained on the wiki. But they are to complex to be intuitive. (In a way they are a basic programming language)
;D
Thanks for the info.

Quote
Quote
I updated Lazarus trunk via FCPupDeluxe and now I can no longer fold everything using Shit+Alt+0. So what do I have to use now for this?
This should still work. Please check your keymap setting, as in the attached image.

I run fpcupdeluxe another time to update trunk despite there are no new commits, and now it works again. Strange.

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 9755
  • Debugger - SynEdit - and more
    • wiki
Re: Unfolding bug after searching
« Reply #8 on: April 20, 2021, 09:06:25 pm »
Quote
All (Nodes)
I changed the text for that to "All on line (Nodes)"

The "Nodes" part is, because this is used as the name in the dialog. Even though it is not of much meaning in the grid. (But for other options it is needed to be repeated)


Quote
- either a menu or a context menu option, to unfold everything to level 0
"to level 0" is just a fancy way to say: unfold all / remove all folds?

If you have folded lines, then the fold gutter context menu has that entry.

Yes, I meant to completely fold, like using Alt+Shift+1.
I don't see this in the context menu. I right-click onto the + icon in front of a procedure and get the attached.

So when I right-click onto the icon in front of a folded procedure I get a content option to unfold all, but when I right-click onto the icon in front of an unfolded procedure I get no context option to fold all.
It looks like you got the image when you clicked on a [ - ], not on a [ + ] ? Because the first line in the context menu has the [ - ] too.

You need to have at least one folded line in the file, in order to see the entry. If there is no folded line the entry is not in the menu (I.e there is no disabled entry, the entry is dropped entirely).

If you do have at least on fold, then you should get "unfold" all, anywhere you right click the fold part of the gutter.

Quote
I run fpcupdeluxe another time to update trunk despite there are no new commits, and now it works again. Strange.
Ends well, all's well.
« Last Edit: April 20, 2021, 09:14:31 pm by Martin_fr »

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 9755
  • Debugger - SynEdit - and more
    • wiki
Re: Unfolding bug after searching
« Reply #9 on: April 20, 2021, 09:13:48 pm »
Btw, bit off topic, but useful for editing large code....

I used to do a lot of folding. Nowadays, I don't, I use a 2nd (or even 3rd) editor window.
Of course that depends on your monitor size.

The IDE can have the same unit open in 2 or 3 or more Windows. Each window scrolled to a diff location in the file. All windows are synchronized.

Look at the context menu of the editor tabs. "Clone to window"

Btw "Lock Page" will prevent the IDE from scrolling the view in that window, when you use code navigation. That is the IDE will rather switch to another window with that unit open, and only if no other option then it will scroll the locked view.
Useful, if you have the class declaration open in one window, and edit the implementation in the other window. Lock the window with the declaration.



Muso

  • Sr. Member
  • ****
  • Posts: 356
Re: Unfolding bug after searching
« Reply #10 on: April 21, 2021, 07:33:59 pm »
It looks like you got the image when you clicked on a [ - ], not on a [ + ] ?
You need to have at least one folded line in the file, in order to see the entry.

Yes, I click onto the [ - ] and need a context menu entry to FOLD everything. Instead I get the option to UNfold. But why UNfold an already unfolded section?
I mean when clicking on a [ + ] I get a context menu to UNfold, so why not also the other way round?

And as you can see in the attached screencast, I already have folded lines in the document.

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 9755
  • Debugger - SynEdit - and more
    • wiki
Re: Unfolding bug after searching
« Reply #11 on: April 21, 2021, 08:05:41 pm »
The "unfold all" relates to the entire file.
It is not specific to the current fold node. => If any where in the file there is any code  folded, then "unfold all" ("all" as in all lines in the file) will be shown.

A "fold all" does not exist. It only exists via the keyboard.

The word "all" is problematic, since there is
- all in the flie
- all on the line


If you want to take a look
Code: Text  [Select][+][-]
  1. \ide\sourcesyneditor.pas  
  2. class  TIDESynGutterCodeFolding (and the base class in synedit).
Code: Pascal  [Select][+][-]
  1. TIDESynGutterCodeFolding.CreatePopUpMenuEntries
adds some of the entries.

You can see the callbacks, like to fold comments
Code: Pascal  [Select][+][-]
  1. then AddPopUpItem(synfFoldCommentsInSelection).OnClick := @PopClickedFoldComment

Where you can see how it walks the lines of the unit, and makes the folds....

---
Or Search for  "ecFoldLevel1" to see how to fold all. (Or send it to Synedits.CommandProcessor)



Muso

  • Sr. Member
  • ****
  • Posts: 356
Re: Unfolding bug after searching
« Reply #12 on: April 21, 2021, 10:40:00 pm »
A "fold all" does not exist. It only exists via the keyboard.

And this is what I want. Just an option (not necessarily in the context menu) that offers the same functionality like Alt+Shift+1.

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 9755
  • Debugger - SynEdit - and more
    • wiki
Re: Unfolding bug after searching
« Reply #13 on: April 22, 2021, 12:56:15 am »
Well, IMHO (but I accept it is for you) a plain "fold all" is not to appealing, because depending on fold settings, it could fold entire "interface" and "implementation" sections. (They can be folded, if enabled).
Or it could fold global level type/var blocks => almost the same as "interface".

A "fold all ..." where ... is in the list of procedures, classes, ..., even except. That I can see appealing.
But having them all in the menu at the same time, would be to much.
So some selection logic would have to apply. (Enable via options, nested sub menu, match elements on current line...)
In any case, at current, I have a big amount of other TODO. So I wont work on them myself.


The closest you can get with the current IDE is using the advanced mouse option.
They can map almost any key-stroke command to a mouse click.
So you could use middle mouse on the fold gutter, or maybe even double left click.

On my earlier image:
Step 2 would be "Fold tree"
Step 3 skipped
Step 5
- set to middle click / you can try double click
- Action: Ide Command
- Once the action is set, a very long list will be in the 2nd dropdown, and it will contain "fold to level 1" (unfortunately they are not ordered....)




Muso

  • Sr. Member
  • ****
  • Posts: 356
Re: Unfolding bug after searching
« Reply #14 on: April 22, 2021, 02:54:24 am »
A "fold all ..." where ... is in the list of procedures, classes, ..., even except. That I can see appealing.

This is what I already proposed in https://forum.lazarus.freepascal.org/index.php/topic,54240.msg402913.html#msg402913

- right-click on the + icon in front of a procedure/function and get in the context menu the option to un/fold all procedures/functions (like already implemented for comments)
- same as above but for all except blocks

Quote
But having them all in the menu at the same time, would be to much.

Why the same time? The idea is to click on the [ +/- ] icon of e.g. an except block and then get the context menu to un/fold all except blocks.

Concerning the fold all feature I only don't understand why there is a shortcut for this but no menu entry. I had to google around if and how this is possible and I think it would be nice when users can find this on their own in one of the menu.

However, I don't insist on anything, just making proposal. I am a happy user of Laz 2.1 and hope to get a final release of it soon. I am an OpenSource developer too in another project (Qt/C++, however) and know that the spare time is limited.
This way thanks for all you great work. I mean I reported the last days several issues and all have already been fixed. This is really amazing!
« Last Edit: April 22, 2021, 03:10:22 am by Muso »

 

TinyPortal © 2005-2018