Forum > Editor

Unfolding bug after searching

(1/5) > >>

Muso:
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

Martin_fr:
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  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---if a then begin if b then beginhas 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:

--- Quote from: Martin_fr on April 20, 2021, 04:29:28 am ---Well and as you can see in your image, the symbol at the start of that line changes.

--- End quote ---

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:
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.


--- Quote from: Muso on April 20, 2021, 10:56:12 am ---provide hiding when a line is selected

--- End quote ---

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?

--- End quote ---
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.

--- End quote ---

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:
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

Navigation

[0] Message Index

[#] Next page

Go to full version