Forum > IDE/CodeTools
Unknown Identifier Search
Tony Stone:
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:
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:
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:
--- Quote from: Tony Stone 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?
--- End quote ---
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:
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....
Navigation
[0] Message Index
[#] Next page