[Lazarus] Some source editor context menu items broken

Michael Van Canneyt michael at freepascal.org
Sun May 21 10:48:30 CEST 2023



Hello,

The refactoring context menu item and the find identifier references context
menu are broken.

Type
   TSourceParser = Class(TObject)
    function ParseSource: TPasModule;
   end;

With the cursor on "ParseSource", the 'Find identifier references' and 'Rename
identifier' menu items in the context menu are grayed out. (plus some
others)

The same problem exists if the cursor is on "ParseSource" in the
implementation:

function TSourceParser.ParseSource: TPasModule;

I did some digging, and it seems to me that the error is in the
TCustomSynEdit.CaretAtIdentOrString routine, which does not detect an
identifier correctly.

It seems a bit strange to me that the syntax highlighter is used to
determine whether the cursor is on a identifier or something else.

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

Any solutions ?

Michael.


More information about the lazarus mailing list