hellooops / vscode-edi-support

Format, highlighting, hover supports for X12 and EDIFACT in vscode.
MIT License
11 stars 6 forks source link

Prettify not taking into account the escape character #3

Closed fsohet closed 11 months ago

fsohet commented 12 months ago

Hello,

I've noticed that your option "Prettify" and "Minify" doesn't work properly. While it works fine for the sub-element character ":" when escaped like this "?:", it is causing issues with the segment separator, when escaped ("?'").

This example: FTX+ZZZ+++I?'ve a:dream that I'll share with you'

Expected "Prettify" would be: FTX+ZZZ+++I?'ve a:dream that I?'ll share with you'

Case 1:

Case 2:

I hope this is clearly explained and I hope your script will be updated to take this into account.

Thanks a bunch !

hellooops commented 12 months ago

Hello,

I've noticed that your option "Prettify" and "Minify" doesn't work properly. While it works fine for the sub-element character ":" when escaped like this "?:", it is causing issues with the segment separator, when escaped ("?'").

This example: FTX+ZZZ+++I?'ve a:dream that I'll share with you'

Expected "Prettify" would be: FTX+ZZZ+++I?'ve a:dream that I?'ll share with you'

Case 1:

  • When applying "Prettify", the (wrong) result obtained is: FTX+ZZZ+++I?' ll' → A portion of the text has been erased and there is a carriage return after the single quote character
  • When applying "Minify" (after prettify), the result is: FTX+ZZZ+++I?'ll'

Case 2:

  • Same example but I directly press "Minify", it directly modify the EDIFACT as follow: FTX+ZZZ+++I?'ll'
  • Pressing "Prettify", gives this: FTX+ZZZ+++I?' ll'

I hope this is clearly explained and I hope your script will be updated to take this into account.

Thanks a bunch !

Thanks for pointing out this issue. I've fixed it in the latest version.

Now escaped segment / element delimiters are supported. The release character could also be customized by setting the UNA-04.

Minify and Prettify are both working for the following example:

UNA:+.!*'
UNB+UNOB:3+ + +231103:1214+000000003+000000001+++++'
UNH+1+ORDERS:D:97A:UN:ED17A1'
BGM+105+K12345+9'
FTX+ZZZ+++I!'ve a:dream that I!'ll share with you'
FTX+ZZZ+++I!'ve a!:dream that I!'ll share with you'
fsohet commented 12 months ago

Very nice ! Thanks for the quick fix. I was about to mention the UNA as well but you did it proactively. Very nice.