barrettotte / vscode-ibmi-languages

Syntax highlighting for IBM i languages such as RPG, CL, DDS, MI, and RPGLE fixed/free.
https://marketplace.visualstudio.com/items?itemName=barrettotte.ibmi-languages
MIT License
33 stars 13 forks source link

RPGLE language needs `wordPattern` to include punctuation #136

Open worksofliam opened 7 months ago

worksofliam commented 7 months ago

Characters like #, $ and $ are valid in RPGLE variables and I believe this affects how the language server makes suggestions also.

worksofliam commented 7 months ago

https://code.visualstudio.com/api/language-extensions/language-configuration-guide#word-pattern

barrettotte commented 7 months ago

@worksofliam Sorry for the late response on this. But, am I able to just modify the sample in that link you provided?

I added this to rpgle.language-configuration.json:

"wordPattern": "(-?\\d*\\.\\d\\w*)|([^\\`\\~\\!\\%\\^\\&\\*\\(\\)\\-\\=\\+\\[\\{\\]\\}\\\\\\|\\;\\:\\'\\\"\\,\\.\\<\\>\\/\\?\\s]+)"

Which just removes $ and # (@ was already not included) from the word pattern.

I tried to test by double clicking st in the following example:

**free

dcl-s @te@st@ char(16) inz(*blanks);
dcl-s #te#st# char(16) inz(*blanks);
dcl-s $te$st$ char(16) inz(*blanks);

I would have expected it to highlight the entire word, but did not: image

I may be not understanding this issue, is there anything obvious I'm missing?

chrjorgensen commented 7 months ago

I don't know if it has any significance, but even though the three characters are valid in variable names, they are also variant characters and are not the same, if the user does not use CCSID 37 (US).

E.g. in Danish (CCSID 277) @#$ appear as ØÆÅ.

We made quite some effort in the C4i extension to ensure these characters were converted correctly when showing system names for libraries, objects and members.

The use of these characters in variable names are not recommended anymore, due to their variance. And I actually quite like that they are not considered part of the name, which indicates to the user, that they are special and should be avoided.

@worksofliam Your thoughts on this? I know they are used historically, but maybe this issue could speed up the change? 😉

worksofliam commented 7 months ago

@barrettotte

I would have expected it to highlight the entire word, but did not:

I would have expected that too. Not sure why it wouldn't. Maybe there is more work the language server needs to do.

barrettotte commented 2 months ago

@worksofliam Jeez I didn't think 4 months passed. But, anyway I think I may have solved this in https://github.com/barrettotte/vscode-ibmi-languages/commit/fbdd48d11f7e87a48686f21bfd5f4f9e5a22f226

I think I was misunderstanding what behavior I was supposed to be seeing. In short, I was expecting double click to highlight the whole identifier. But, what actually needed to happen is when single clicking the identifier a light highlight appears on the identifier. I think this is what you needed.

Let me know what you think and if I can close this out

barrettotte commented 2 months ago

Additional identifier regex for troublesome CCSIDs added by @chrjorgensen in https://github.com/barrettotte/vscode-ibmi-languages/pull/139