vscode-ibmi-languages icon indicating copy to clipboard operation
vscode-ibmi-languages copied to clipboard

RPGLE language needs `wordPattern` to include punctuation

Open worksofliam opened this issue 5 months ago • 4 comments

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

worksofliam avatar Jan 20 '24 18:01 worksofliam

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

worksofliam avatar Jan 20 '24 18:01 worksofliam

@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?

barrettotte avatar Feb 06 '24 05:02 barrettotte

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? 😉

chrjorgensen avatar Feb 06 '24 20:02 chrjorgensen

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

worksofliam avatar Feb 06 '24 21:02 worksofliam