Recent

Author Topic: "Find declaration" option is used to do two different things  (Read 3206 times)

furious programming

  • Hero Member
  • *****
  • Posts: 864
"Find declaration" option is used to do two different things
« on: January 22, 2024, 03:57:52 pm »
The Find declaration option used to make sense and was actually used to jump to the declaration, but in Lazarus 3.0 it was overcomplicated and broken. Now instead of being used to look for declarations, it can be used to look for implementations, which is absurd! You have made a huge mistake in the terms of usability, now the UX sucks!

The Jump directly to method body option should not exist at all, and instead there should be a new option called Find implementation, for which there should be a separate item in the context menu and a new item in the keyboard settings tree in the IDE settings window. This option should also be added to the mouse settings in the IDE settings window, to be able to assign it for the Ctrl+LMB shortcut (or any other shortcut).



My proposal is as follows:
  • Remove this bullshit called Jump directly to method body from the Codetools→General branch in the IDE settings window.
  • Add a new item in the editor context menu, called Find implementation of %s, enabled only if the identifier is the name of a routine and only if this routine has an implementation (does not apply to e.g. routines imported from a DLL).
  • Add the new option called Find implementation in the Editor→Key Mappings branch and set the default Alt+Down shortcut for it.
  • Add the new option called Jumps to declaration in all comboxboxes in the Editor→Mouse branch.
  • Make it so that a jump to a declaration always actually jumps to a declaration, regardless of whether it is the identifier of a constant, variable, routine, etc.
  • Make it so that a jump to implementation always actually jumps to the routine's implementation, never to its declaration.
  • Set that a jump to an implementation made on an identifier that is not a routine name does nothing (no implementation, so no jump).
Something like this is functional, intuitive and flexible. Since declaration and implementation are two completely different things, there should be two separate options for this, configurable separately and used separately, including two different keyboard shortcuts.



By the way, the Find declaration option is now broken, I reported it — https://gitlab.com/freepascal.org/lazarus/lazarus/-/issues/40714
« Last Edit: January 22, 2024, 04:01:32 pm by furious programming »
Lazarus 3.4 with FPC 3.2.2, Windows 10 — all 64-bit

Working solo on an arcade, action/adventure game in retro style (pixel art), programming the engine and shell from scratch, using Free Pascal and SDL. Release planned in 2026.

Thaddy

  • Hero Member
  • *****
  • Posts: 15516
  • Censorship about opinions does not belong here.
Re: "Find declaration" option is used to do two different things
« Reply #1 on: January 22, 2024, 07:14:55 pm »
ctrl-shift-downarrow, ctrl-shift-uparrow. Is that not enough?
My great hero has found the key to the highway. Rest in peace John Mayall.
Playing: "Broken Wings" in your honour. As well as taking out some mouth organs.

furious programming

  • Hero Member
  • *****
  • Posts: 864
Re: "Find declaration" option is used to do two different things
« Reply #2 on: January 22, 2024, 07:27:31 pm »
Please read the topic again — and again and again, until you understand the essence of the problem.
Also check out the issue I linked to at the bottom of the first post. There's a gif that will help you understand what's going on.



In short: the Find declaration option not only works incorrectly (bug), but also may not be used for what it is intended for, i.e. searching for implementations, not declarations (broken UX design). It can be used for two separate things despite having the same caption. There should be two separate options that do what their name says.
« Last Edit: January 22, 2024, 07:35:53 pm by furious programming »
Lazarus 3.4 with FPC 3.2.2, Windows 10 — all 64-bit

Working solo on an arcade, action/adventure game in retro style (pixel art), programming the engine and shell from scratch, using Free Pascal and SDL. Release planned in 2026.

dbannon

  • Hero Member
  • *****
  • Posts: 3015
    • tomboy-ng, a rewrite of the classic Tomboy
Re: "Find declaration" option is used to do two different things
« Reply #3 on: January 23, 2024, 06:19:59 am »
Yes, I think I agree with Furious, while its possible to find just about everything you want, its not always obvious.

Thaddy, for example, is obviously confused.  Ctrl-Shift-Up | Down.  In the keyboard mapping, they are mapped to "Find Procedure Definition" and "Find Procedure Method". But in practice, they both do the same thing. If the cursor is somewhere in the body of a method implementation, it jumps to that declaration. If cursor is on a declaration, it jumps to the implementation. Both ~/Up and ~/Down do the same thing, toggle back and forth. I wonder why ?

Nothing to do with Furious's issue however. He is talking about jumping based on the identifier under the cursor.

Alt Arrow is described in the keyboard mapping as "Find Declaration" and its behavior is dependent  on the "Jump directly to Method Body" setting, no visible link between that setting and the key mapping.

Honestly, "Jump to Declaration" and "Jump to Implementation" are both important behaviors and having them mutually exclusive does seem a bit strange.

So, I strongly support Furious's proposal (but may not necessarily insist on the strict rules he proposes).

Davo
Lazarus 3, Linux (and reluctantly Win10/11, OSX Monterey)
My Project - https://github.com/tomboy-notes/tomboy-ng and my github - https://github.com/davidbannon

furious programming

  • Hero Member
  • *****
  • Posts: 864
Re: "Find declaration" option is used to do two different things
« Reply #4 on: January 23, 2024, 01:12:44 pm »
As far as I'm concerned, the jump target always matters — sometimes I need to jump to the function declaration, and sometimes I need to jump straight to its body. In previous versions of Lazarus, it was always a jump to the declaration, so to jump to the function body, you had to use two keyboard shortcuts — Alt+Up to jump to the declaration, and then Shift+Ctrl+Up/Down to move to her body.

Adding the Jump directly to method body option didn't change anything in this topic, because you still have to use two keyboard shortcuts, and the difference is that the jump to declaration option actually may jump to the implementation, which is confusing.

Thaddy, for example, is obviously confused.  Ctrl-Shift-Up | Down.  In the keyboard mapping, they are mapped to "Find Procedure Definition" and "Find Procedure Method". But in practice, they both do the same thing. If the cursor is somewhere in the body of a method implementation, it jumps to that declaration. If cursor is on a declaration, it jumps to the implementation. Both ~/Up and ~/Down do the same thing, toggle back and forth. I wonder why ?

This is a mystery to me too. Why are there two options even though they do exactly the same thing? It would be best to combine both of these options into one, after all, one is enough to jump between the declaration and the implementation.
Lazarus 3.4 with FPC 3.2.2, Windows 10 — all 64-bit

Working solo on an arcade, action/adventure game in retro style (pixel art), programming the engine and shell from scratch, using Free Pascal and SDL. Release planned in 2026.

furious programming

  • Hero Member
  • *****
  • Posts: 864
Re: "Find declaration" option is used to do two different things
« Reply #5 on: January 23, 2024, 01:48:41 pm »
Now we have a hell of a problem, because the change was introduced in the IDE, and we will have to wait many months for the next stable version of Lazarus. Navigation in the code editor has been broken and we will have to deal with this for a long time...



Currently, the only solution that allows consistent operation and to choose the jump target (declaration or implementation) is to use this new option and IDE macros. You should check the Jump directly to method body option so that Alt+Up always takes you to the implementation, and then record an IDE macro containing two items — Find declaration (i.e. jump to the implementation) and then Find Procedure Definition (jump from body to declaration). Then set the Alt+Down shortcut for this macro.

The macro should have the following content (see attachment):

Code: Pascal  [Select][+][-]
  1. begin
  2. ecFindDeclaration;
  3. ecFindProcedureDefinition;
  4. end.

From now on, pressing the Alt+Down shortcut will execute a macro, first simulating pressing Alt+Up and then Shift+Ctrl+Up. If you jump to a routine declaration, the macro will do it for you, but if you use it on the identifier of a constant, variable, data type, etc. (something that does not have implementation), the macro will also jump correctly to the declaration of that identifier (the second macro shortcut will do nothing).

The only problem is that you have to get used to the fact that Alt+Up jumps to the routine definition and the fact that using the macro adds two items to the Jump history, so to return to the previous place after jumping, you need to go back twice (press Alt+Left twice).
« Last Edit: January 23, 2024, 06:14:08 pm by furious programming »
Lazarus 3.4 with FPC 3.2.2, Windows 10 — all 64-bit

Working solo on an arcade, action/adventure game in retro style (pixel art), programming the engine and shell from scratch, using Free Pascal and SDL. Release planned in 2026.

TRon

  • Hero Member
  • *****
  • Posts: 3141
Re: "Find declaration" option is used to do two different things
« Reply #6 on: January 23, 2024, 01:51:27 pm »
Now we have a hell of a problem, because the change was introduced in the IDE, and we will have to wait many months for the next stable version of Lazarus. Navigation in the code editor has been broken and we will have to deal with this for a long time...
That is why fixes exit. Now that there was an overhaul in version numbering that also allows for many more bug-fix iterations (which I assume was one of the reasons for the leap in version numbering).
All software is open source (as long as you can read assembler)

furious programming

  • Hero Member
  • *****
  • Posts: 864
Re: "Find declaration" option is used to do two different things
« Reply #7 on: January 23, 2024, 02:10:27 pm »
Subsequent versions of stable Lazarus are released too rarely. Bug-fixes should appear at least every month or two. I know it's a bit more work, but waiting a year for a new version with bug fixes and some new features is definitely too long. Especially for those who don't use the trunk version and don't want to use it (e.g. me).
« Last Edit: January 23, 2024, 02:14:20 pm by furious programming »
Lazarus 3.4 with FPC 3.2.2, Windows 10 — all 64-bit

Working solo on an arcade, action/adventure game in retro style (pixel art), programming the engine and shell from scratch, using Free Pascal and SDL. Release planned in 2026.

dbannon

  • Hero Member
  • *****
  • Posts: 3015
    • tomboy-ng, a rewrite of the classic Tomboy
Re: "Find declaration" option is used to do two different things
« Reply #8 on: January 23, 2024, 11:13:54 pm »
Now we have a hell of a problem, because the change was introduced in the IDE, and we will have to wait many months for the next stable version of Lazarus. Navigation in the code editor has been broken and we will have to deal with this for a long time...
....

Er, wait a minute, the "Jump directly to Method Body" as an option is not new, been there for some time. And its optional, just don't select it.

The real problem IMHO is that you have to choose, you can have quick access to the definition or the implementation, NOT both.  Thats all that needs be fixed. I agree that the "Jump..." option in Code Tools was a silly way of dealing with the problem, drop it, make a new  "Find implementation" and, by default map it to Alt-Down.  As furious  suggested in his first post. The code to do so must already exist, its 'just' a UI change.

Davo
Lazarus 3, Linux (and reluctantly Win10/11, OSX Monterey)
My Project - https://github.com/tomboy-notes/tomboy-ng and my github - https://github.com/davidbannon

MarkMLl

  • Hero Member
  • *****
  • Posts: 7485
Re: "Find declaration" option is used to do two different things
« Reply #9 on: January 23, 2024, 11:29:30 pm »
ctrl-shift-downarrow, ctrl-shift-uparrow. Is that not enough?

No, it's not. We're both old enough to remember when word processors required amusing key combinations, and both old enough to find the amusement turning to discomfort. And we're both old enough to remember when people complained that the uniform UI introduced by MS Windows (albeit largely based on IBM CUA) would stifle innovation.

And I've seen commercial keyboards that would make your blood run cold.

I'm sorry, but I'm dead against having to remember key combinations. One of the strong points of the Windows-style UI was that you could navigate through a menu sequence which would give you a reasonable idea of what you were about to do /before/ /you/ /did/ /it/, and might also hint at a key combination if you wanted to do it again in the short term.

Having to remember key combinations (i.e. as you suggest is optimal for the Lazarus IDE), or having to remember outre gestures (as required by Android etc.), has no place in decent user interface design.

MarkMLl
MT+86 & Turbo Pascal v1 on CCP/M-86, multitasking with LAN & graphics in 128Kb.
Logitech, TopSpeed & FTL Modula-2 on bare metal (Z80, '286 protected mode).
Pet hate: people who boast about the size and sophistication of their computer.
GitHub repositories: https://github.com/MarkMLl?tab=repositories

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 10246
  • Debugger - SynEdit - and more
    • wiki
Re: "Find declaration" option is used to do two different things
« Reply #10 on: January 24, 2024, 01:32:59 am »
Having to remember key combinations
...

"Having" (as in "must do") is not the same as "being given the choice".

IIRC, largely the IDE offers you to use menus for a great many things. Or adding them to toolbars (editor toolbar).
And as for keys, you can map every action to any key you want.

The way that is to be configured could be improved, given the amount of actions that can be chosen to be assigned to keys => but that is a (at least slightly) different topic.



If you ask me, I like the Emacs concept of major and minor modes that affect the key-mapping, and that you can toggle when you need.... But well everyone has their own likes.

MarkMLl

  • Hero Member
  • *****
  • Posts: 7485
Re: "Find declaration" option is used to do two different things
« Reply #11 on: January 24, 2024, 08:07:37 am »
Having to remember key combinations
...

"Having" (as in "must do") is not the same as "being given the choice".

Correct. It's absolutely fine to have a shortcut for when one's doing something that is likely to require repetitive action. It's not fine to not have that shortcut hinted at by some appropriate item in the menu tree.

MarkMLl
MT+86 & Turbo Pascal v1 on CCP/M-86, multitasking with LAN & graphics in 128Kb.
Logitech, TopSpeed & FTL Modula-2 on bare metal (Z80, '286 protected mode).
Pet hate: people who boast about the size and sophistication of their computer.
GitHub repositories: https://github.com/MarkMLl?tab=repositories

dbannon

  • Hero Member
  • *****
  • Posts: 3015
    • tomboy-ng, a rewrite of the classic Tomboy
Re: "Find declaration" option is used to do two different things
« Reply #12 on: January 24, 2024, 11:51:52 am »
Mark, Martin, at risk of straying back on to topic again ....

Its a given that Lazarus defines a number of "things" that can be mapped to certain keyboard combinations. Some people like to use them. However, one of those "things", called "Find declaration" should be complemented with one called "Find Implementation". Instead we are offered a Code Tools option to make the "Find Declaration" thing, behave like a misnamed "Find Implementation". But we cannot have both.

And both would be very useful to those of use who like to use key board short cuts. And could be ignored by everyone else.

Seriously, I don't remember any more than a dozen or so key combinations but they are really useful when jumping around in existing code.

Davo
Lazarus 3, Linux (and reluctantly Win10/11, OSX Monterey)
My Project - https://github.com/tomboy-notes/tomboy-ng and my github - https://github.com/davidbannon

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 10246
  • Debugger - SynEdit - and more
    • wiki
Re: "Find declaration" option is used to do two different things
« Reply #13 on: January 24, 2024, 12:20:25 pm »
However, one of those "things", called "Find declaration" should be complemented with one called "Find Implementation". Instead we are offered a Code Tools option to make the "Find Declaration" thing, behave like a misnamed "Find Implementation". But we cannot have both.

And both would be very useful to those of use who like to use key board short cuts. And could be ignored by everyone else.

Not disagreeing.

But the better way to get anything done is a feature request (bug tracker). I can't tell if anything will come of it.
It can be accomplished by an offer to a patch, but again: no idea if it will further the case or not.

 

TinyPortal © 2005-2018