icsharpcode / AvalonEdit

The WPF-based text editor component used in SharpDevelop
http://avalonedit.net/
MIT License
1.85k stars 469 forks source link

Prioritize longer keywords also when they're not alphanumeric #389

Closed ltrzesniewski closed 1 year ago

ltrzesniewski commented 1 year ago

I noticed the following issue in ILSpy:

image

Note that clt is highlighted instead of clt.un.

This PR fixes this by making sure longer keywords are always preferred. Currently, this logic is only applied if every keyword in the list starts and ends with an alphanumeric character.

christophwille commented 1 year ago

@dgrunwald could you please review this? @siegfriedpammer isn't sure.

goswinr commented 1 year ago

If you put the longer keyword at a higher position in the xshd file it would work too, no?

siegfriedpammer commented 1 year ago

If you put the longer keyword at a higher position in the xshd file it would work too, no?

Yes, I just tried it. Fixes the problem as well... this change is not strictly required, but might be good to use the same logic in both cases.

ltrzesniewski commented 1 year ago

Yes, that's a workaround, but I wanted to fix the root cause. If this PR ends up not being accepted, I'll submit a fix to ILSpy directly.

The current behavior surprised me, as I expected the xshd keywords to behave like a set: their order shouldn't matter. In the ILSpy case, the presence of prefix IL instructions such as tail. (with the dot at the end) changes the behavior of the whole keyword list.