Skip to content
This repository has been archived by the owner on Apr 2, 2024. It is now read-only.

Escape Character "\" causing format issues when escaping "~" #256

Closed
johnnyhaff opened this issue Mar 7, 2019 · 6 comments
Closed

Escape Character "\" causing format issues when escaping "~" #256

johnnyhaff opened this issue Mar 7, 2019 · 6 comments

Comments

@johnnyhaff
Copy link

johnnyhaff commented Mar 7, 2019

Description of the Issue

When using \ to escape a ~, the formatting of everything after that turns yellow and the plugin doesn't recognize any procedures, functions, etc after it.

Steps to Reproduce the Issue

In my instance am doing a database query which the field might contain the literal value of ~ as a delimiter, My query would look similar to this:
FIND FIRST someTable WHERE NUM-ENTRIES(someField, "\~") >= 2 NO-ERROR. IF AVAILABLE someTable THEN DO: [some code....] END.
Notice that everything after NUM-ENTRIES(someField, "\~") is turned to yellow. If you have other define procedures further down in your code, they no longer show up in your Code Explorer.

Expected Behavior

I would expect that the \ would be considered a valid escape character as mentioned here in KB000020457. This code is being run on a Unix platform.

Actual Behavior

Screenshots

Debug Information

3P Version: v1.8.4 x64
NPP Version: v7.5.9 x64

@jcaillon
Copy link
Owner

Hello @johnnyhaff,

I'm not sure that I understand what you are trying to achieve? Is the backslash \ here to escape the ~ character? To my knownledge, the only escape character in openedge is ~ and it should be escaped by doubling it (i.e. ~~).

If i put this statement in a new file:

MESSAGE "\~".

I can reproduce the behavior you describe. But this is because the code does not compile. The ~ escapes the final double quote so the string is never ended.

image

Does this code compile on your end?

@jcaillon
Copy link
Owner

I will add that if you want to match a literal \~, you string should be \~~. This will compile correctly and the syntax highlight will be correct as well in 3P.

@johnnyhaff
Copy link
Author

Hi @jcaillon,
The backslash ("") is used as an escape character which is valid on a Unix platform as mentioned here: KB000020457. The code I'm developing is run on Unix so it would be valid. Sorry I don't think my initial post was very clear so I updated it just now.

@johnnyhaff johnnyhaff changed the title Literal "\~" causing format issues Escape Character "\" causing format issues when escaping "~" Mar 11, 2019
@jcaillon
Copy link
Owner

Oh... So the code compiles on linux but not on windows; a shame for a cross-platform language :/

My toughts:

  • It kind of sucks because this means I have to know, at parse time, on which platform the code will be compiled. The only solution is letting the user specify whether or not to use linux escape char in parser (a toggle option).
  • however, since 3P can only compile your code with a windows executable, it doesn't make much sense to correctly parse the code if it does not compile when you press ALT+F1.
  • It seems developer studio does not handle this case better than 3P :

image

Before using 3P, did you edit your code directly on the linux machine?

As a best practice, I would say it is much better to use the cross-platform escape char ~, but can understand if you don't want to modify legacy code.

I don't know if I should handle this special case, giving the fact that 3P is a windows tool. What do you think?

@johnnyhaff
Copy link
Author

It does compile on Linux, however we generally don't compile code that runs on Linux, only Windows code gets compiled. And, for that reason is probably why this has never been picked up by the compiler for so long. Once moving to 3P I started noticing the formatting issues. This is legacy code so it might be difficult to update, but using "~~" to escape the tilde does work in Linux.
The only other way I see this being handled differently by 3P is if you added a Unix compile option in Settings as you suggested but I feel like this might not be worth the effort for just this one "issue". I'll work on updating my code instead. Thank you for considering my post and talking it through with me!

@jcaillon
Copy link
Owner

Thank you for your understanding. I will keep that in mind if I rewrite the parser. But yes, for now, it does not seem to be a priority feature.

Best regards

jcaillon added a commit that referenced this issue Jan 11, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants