Recent

Author Topic: Unknown Identifier Search  (Read 2032 times)

Tony Stone

  • Full Member
  • ***
  • Posts: 219
Unknown Identifier Search
« on: February 14, 2023, 03:07:58 pm »
So after thousands of errors about unknown identifiers when I am testing code I find online I just last night discovered that Lazarus can search your units for the identifier.  Then with a simple right click it can add the found unit to your use section.  I love it.  Wish I knew about it years ago.  Which makes me think maybe there could be a "smart" message to go with an unknown identifier error?  Meaning if the IDE knows that identifier is in xx unit it will give you that as a message?  Or maybe the first time the IDE ever encounters the error it offers the user the method to search your units?  Then that message could have a simple don't show this message again check mark.  Just a thought for new users.  I never knew the search tool was in there.  I could be way off on this idea.  Just curious what others think.

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 9791
  • Debugger - SynEdit - and more
    • wiki
Re: Unknown Identifier Search
« Reply #1 on: February 14, 2023, 04:33:08 pm »
I agree the "quick fix" feature has very low visibility. Not sure though, how best to improve.

I don't think that "auto repeating" the fix is a good idea.
- If you have the same identifier several times in the unit, then fixing it once (by inserting the needed unit into the uses clause) will fix the rest too.
- If it is another ident, you need to check if the offered unit is correct.
- If it is the same ident, but in a diff unit, then again the fix may not be the same, the ident could be from another unit too.

Even if you fix the first ident in a unit by updating the uses clause, later idents of the same name could be from other units.



Btw, you may want to install package cody, which adds the "Show Unit / Identifier dictionary" to the "Source" menu. It can find units even from packages that you haven't yet added to the project. And you can start typing, and it searches by prefix. (The normal drop down code completion only finds identifiers from units already in the uses clause)

Also read https://wiki.lazarus.freepascal.org/Lazarus_IDE_Tools

Tony Stone

  • Full Member
  • ***
  • Posts: 219
Re: Unknown Identifier Search
« Reply #2 on: March 22, 2023, 12:41:15 pm »
I have a bug with using the Search Edentifier tool when i have 2 code editors docked side by side.  When the Identifier search is searching the code editor that had focus scrolls very far to the right by about 200, some times more like 400 characters or more to the right.  Not sure if this is an issue in the editor or the Identifier Search.  Anyone else experience anything like this?

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 9791
  • Debugger - SynEdit - and more
    • wiki
Re: Unknown Identifier Search
« Reply #3 on: March 22, 2023, 01:17:12 pm »
I have a bug with using the Search Edentifier tool when i have 2 code editors docked side by side.  When the Identifier search is searching the code editor that had focus scrolls very far to the right by about 200, some times more like 400 characters or more to the right.  Not sure if this is an issue in the editor or the Identifier Search.  Anyone else experience anything like this?
Can't say I had. But lets clarify some points
- "scrolls 200/400 horiz-right" => I assume the identifier isn't on a line that is that long?
- And then also, you have enabled/allowed "caret past EOL" ? (otherwise it couldn't go there, if the line is shorter)

Then we have to consider it could be an issue in docking. (which I don't use, and then would explain I haven't seen the issue).

And if it relies on a 2nd editor being open. Does that 2nd editor
- show the same file
- has lines that are that long (so that maybe the position was meant for the 2nd editor)

Also, when does it happen?
- during the search
- automatically at the end of the search
- when you click a found-result in the "search result" window?
  (And are there results found?)
- Only when the search ends in an error (messages window)
  (Or no search results shown?)

Tony Stone

  • Full Member
  • ***
  • Posts: 219
Re: Unknown Identifier Search
« Reply #4 on: March 22, 2023, 01:26:14 pm »
Yes I have scroll past EOL enabled.

It seems to scroll horizontally as soon as the search is started.  I am starting the search from the message window list


I say it is only when I have the editors docked side by side because that is my layout on my desktop monitors(very large)... On my laptop I do not see this issue but i also dont use cloned and docked editors on the lap top.


Last night I seem to have noticed it is scrolling further to the right the larger the unit is.  I.E. 1000 lines scrolls further to the right than a unit that has 500 lines.

No errors, not sure if this is happening only when no results are found.

When I get home tonight I will see if I can sort out some better details and try to explain steps to make it reproduceable for others.

I also want to say yes, the same unit are often opened in both editors.... 
« Last Edit: March 22, 2023, 01:30:13 pm by Tony Stone »

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 9791
  • Debugger - SynEdit - and more
    • wiki
Re: Unknown Identifier Search
« Reply #5 on: March 22, 2023, 01:34:12 pm »
I am starting the search from the message window list

Last night I seem to have noticed it is scrolling further to the right the larger the unit is.  I.E. 1000 lines scrolls further to the right than a unit that has 500 lines.

SO then the message in the message window has a location? What is it?

Any relation between that, and the editor pos? After the scroll, the editor status bar ought to show line and column. Maybe it went to the column, that should have been the line?

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 9791
  • Debugger - SynEdit - and more
    • wiki
Re: Unknown Identifier Search
« Reply #6 on: March 22, 2023, 01:36:57 pm »
Well, that was easy to test
Code: Text  [Select][+][-]
  1. testwatches.pas(64,5) Error: Identifier not found "xResultDBGType"

"Search identifier" and the editor jumps to line 5, column 64.  The error however was at line 64 column 5.

Tony Stone

  • Full Member
  • ***
  • Posts: 219
Re: Unknown Identifier Search
« Reply #7 on: March 22, 2023, 01:49:02 pm »
Ahhh... so it wasn't me losing my mind!  I'm here reconfiguring my laptop to try and reproduce it.(I am supposed to be working. lol).  So maybe it's a simple fix...

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 9791
  • Debugger - SynEdit - and more
    • wiki

Tony Stone

  • Full Member
  • ***
  • Posts: 219
Re: Unknown Identifier Search
« Reply #9 on: March 22, 2023, 02:03:44 pm »
Thank you Martin!  I just realized even on my laptop it IS doing it but I was not noticing it because I was putting my error at like the 10th line!  So it wasn't behaving the same on my laptop as obviously as it does on larger files on my desktop! Either way you guys are the best.  But at the same time this is why I came here to sort out the bug before I even considered submitting a bug.  I have done that in the past when it is my own error and I feel really stupid wasting developers time on a non-existent bug.   :-[
« Last Edit: March 22, 2023, 02:14:04 pm by Tony Stone »

 

TinyPortal © 2005-2018