Don't you believe this? I found yet another broken GExperts functionality. This time it isn't my fault, it had been broken since Delphi 8 but apparently nobody noticed:

Don't you believe this? I found yet another broken GExperts functionality. This time it isn't my fault, it had been broken since Delphi 8 but apparently nobody noticed:
The "Previous/Next Identifier reference" editor expert hasn't been work correctly since the IDE internally uses UTF-8 encoding.

I for one didn't even know about these experts. Never used them, which is a shame because they can be quite useful.

The Delphi IDE is running out of keyboard shortcuts by the way, and it gets worse with every additional expert.

Originally shared by Thomas Mueller (dummzeuch)

GExperts now compiles without a single hint in all Delphi versions from 6 to XE8.

Hooray!

(and that's not because I disabled them ;-) )

I also fixed a unicode problem with the procedure list, which is what got me started:

procedure blä;
procedure blüb;
procedure plöp;

now all work fine. The problem was with Martin Waldenburg's Delphi parser. Of course he can't be blamed for this because his work was done before Delphi was unicode aware.

Comments

  1. I use the prev/next identifier a lot, and did not notice any malfunction (XE...XE8), except that sometimes the shortcuts stop working.

    ReplyDelete
  2. The calculation between offset and cursor positions were wrong, because they relied on OTA functions that expect UTF-8 strings, but the actual strings were native either ANSI or Unicode.

    ReplyDelete
  3. Thanks for spending your time on it Thomas Mueller​

    ReplyDelete
  4. I tried to use them, noticed they didn't work, and then promptly forgot about them until I saw your post :/

    ReplyDelete
  5. Thomas Mueller I've just tried to compile GExperts trunk version with XE7, but it fails in GX_ePrevNextIdentifier.pas;  TBaseIdentExpert.Execute, with error "undeclared identifier: 'GetCurrentCharPos'". It should be in TEditReader, but it isn't. Did you forget to commit some changes?

    ReplyDelete
  6. It's one of the reasons I switched most of those kinds to ModelMaker Code Explorer. Are you going to fix the GExperts one?

    ReplyDelete
  7. Achim Kalwa are you sure it's the current code? I compiled and tested it for Delphi 6, 2007 and XE8 before committing the changes. I didn't try XE7 though. And I'm pretty sure I committed both units with the same commit. Odd. I'll check next time I'm at the computer.

    ReplyDelete
  8. Achim Kalwa Apparently I did not commit the changes to the TEditReader :-(
    I'll fix that tonight.

    ReplyDelete
  9. Thank you, Thomas, for your work on the GExperts! Perhaps I can now hunt down this nasty ProofReader-bug, when unintentionally typeing foö inserts garbage into the code editor.

    ReplyDelete
  10. Thomas Mueller The find prev/next delimiter expert doesn't work as expected with your modifications: As soon as there are some non-ascii chars (äöü) at the beginning of the file (i.e. as comment), your new function GetFileContent() returns a wrong position. This is because EditRead.GetCurrentBufferPos gives an index for an Ansi or UTF-8 editor buffer, but "FileContent" is converted to string. The more umlauts are present in the text, the more the position drifts away.
    Simple test case:

    // äöüÄÖÜ
    unit Unit1;
    Interface
    Implementation
    procedure Foo;
    begin
    //
    end;
    end.

    Place the cursor onto "begin" and press Ctrl+Alt+Right.
    Now remove the first line and try again.

    Any idea how to fix this?

    ReplyDelete
  11. Achim Kalwa​ That's probably the same problem I fixed in the prev/next identifier expert. I'll have a look after dinner.

    ReplyDelete
  12. Achim Kalwa it was exactly the same problem. I think I fixed it now.

    ReplyDelete
  13. Thomas Mueller Yes, looks good now. Almost. The message telling that "%s is not a suppored delimiter" (SNotValidIdentifier, TBaseDelimiterExpert.Execute) is mangled because of "HackBadEditorStringToNativeString". I've solved this by copying TextToken into a new string-for-message variable before calling HackBadEditorStringToNativeString.

    ReplyDelete

Post a Comment