On 21/05/2023 11:38, Mattias Gaertner via lazarus wrote:
On Sun, 21 May 2023 10:48:30 +0200 (CEST)
Michael Van Canneyt via lazarus <lazarus@lists.lazarus-ide.org> wrote:
[...]
I saw a remark in main.pp that this is supposed to be faster than
using the codetools:
CurWordAtCursor := ASrcEdit.GetWordAtCurrentCaret;
//it is faster to get information from SynEdit than from
CodeTools
ASrcEdit.EditorComponent.CaretAtIdentOrString(ASrcEdit.EditorComponent.CaretXY,
IdentFound, StringFound);
Faster? Probably. Correct? clearly not (yet).
Problem is that this function checks:
AtIdent := Attri = Highlighter.IdentifierAttribute;
But TSynPasSyn has its own attribute
ProcedureHeaderName: TSynHighlighterAttributesModifier
Yes that is broken in SynEdit.
This is related to procedure names having a color of their own.
Same probably happens for case-labels
"case enum of" and then the named enum-members as labels.
Yet in that case there is no easy way to differentiate between
identifier (enum member name) and else/otherwise (keyword).
That should be reported as a bug. (It may need a more substantial fix to
be future-safe / a dedicated function in the HL maybe)
-------------------
Using CaretAtIdentOrString is questionable anyway.
Afaik codetools also works on comments.
At least "find identifier references" (if invoked via key combo) works
on idents in comments.
Yet CaretAtIdentOrString does by design not return true for comments.
So "git blame" the source editor, and see what was used before
CaretAtIdentOrString.
--
_______________________________________________
lazarus mailing list
lazarus@lists.lazarus-ide.org
https://lists.lazarus-ide.org/listinfo/lazarus