You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The issue very inconsistent and only appears if this code is preceded by a specific set of character strings used as variables. I have a full reprex narrowed down, but I cannot share it publicly. If you are interested, please contact me via email and I'll send it.
Thanks @tonytonov for reporting this. I assume you are running styler 1.0.1, which was just released on CRAN a few days ago.
I'd definitively like to have a look at a full reprex and I contacted you via email. We had a few issues related to bugs in the R parser, or that's at least what we thought it was. Most notably #100, #187, #259, #327.
Remotely related: In #216, we found that long strings get truncated when parsed, so we worked around that as well.
Great, the reprex is sent. The issues you mention definitely look related, especially #216. There are exactly slightly more than 1000 characters in the preceding string, so I believe that's why I couldn't narrow the reprex even further down.
I suggest you @tonytonov to first capture such a sessioninfo before changing any configurations of you system, so we know afterwards what has caused the problem (once we found it out).
Ok, I found the problem. When implementing #230 as a response to #216, we did assume that the parents of all STR_CONST is an expression expr that contains nothing but the string. In verify_str_txt(), we
then replace text of these token with text of their parent. We do this because text of expr is completely parsed, while text of STR_CONST is only parsed correctly if not exceeding a character limit descried in #216.
This works fine for the below example:
The parent of 4 is 11, which contains the whole expression. If there is any long string in code, alltext of STR_CONST will be replaced with the text of their parents. This is why your @tonytonov example fails.
Hence, we showed that the solution #230 works for quoted arguments, but not for quoted names of the arguments if a long string is present anywhere in the code. Hence, we must find another way of getting text of long strings.
I think we implemented the solution with the parent because there were concerns that extracting text is brittle (#216 (comment)). However, I think there is no way around this. One alternative could be to only replace text of STR_CONST for strings that actually need a replacement (instead of all), but that is not elegant because long quoted argument names would still cause malformatting.
For that reason, I think we can close this issue and repoen #216.
@tonytonov I just merged #384 into master and I think this problem should now be solved via closing #216. Can you confirm this? The solution should also work for the long example you sent me via email.
@lorenzwalthert Thanks for the update! I can no longer reproduce the issue using the development version. I assume this will be included into the next CRAN release? (presumably 1.0.2?)
Le 13 avr. 2018 à 11:00, Anton Antonov ***@***.***> a écrit :
@lorenzwalthert Thanks for the update! I can no longer reproduce the issue using the development version. I assume this will be included into the next CRAN release? (presumably 1.0.2?)
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or mute the thread.
Activity
lorenzwalthert commentedon Mar 14, 2018
Thanks @tonytonov for reporting this. I assume you are running styler 1.0.1, which was just released on CRAN a few days ago.
I'd definitively like to have a look at a full reprex and I contacted you via email. We had a few issues related to bugs in the R parser, or that's at least what we thought it was. Most notably #100, #187, #259, #327.
Remotely related: In #216, we found that long strings get truncated when parsed, so we worked around that as well.
tonytonov commentedon Mar 14, 2018
Great, the reprex is sent. The issues you mention definitely look related, especially #216. There are exactly slightly more than 1000 characters in the preceding string, so I believe that's why I couldn't narrow the reprex even further down.
lorenzwalthert commentedon Mar 14, 2018
Interestingly, I cannot reproduce the problem on my machine with the code you sent me. With styler 1.0.1, I get (output truncated):
This seems strange since you pointed out in your email that the issue persists with styler 1.0.1
lorenzwalthert commentedon Mar 14, 2018
lorenzwalthert commentedon Mar 14, 2018
I suggest you @tonytonov to first capture such a sessioninfo before changing any configurations of you system, so we know afterwards what has caused the problem (once we found it out).
tonytonov commentedon Mar 14, 2018
Replied via email; in addition to that, here's the current setup:
lorenzwalthert commentedon Mar 14, 2018
Ok, I found the problem. When implementing #230 as a response to #216, we did assume that the parents of all
STR_CONSTis an expressionexprthat contains nothing but the string. Inverify_str_txt(), wethen replace
textof these token withtextof their parent. We do this becausetextofexpris completely parsed, whiletextofSTR_CONSTis only parsed correctly if not exceeding a character limit descried in #216.This works fine for the below example:
Created on 2018-03-14 by the reprex package (v0.2.0).
However, as the following example shows, we cannot assume that the parent only contains the text of
STR_CONST.Created on 2018-03-14 by the reprex package (v0.2.0).
The parent of 4 is 11, which contains the whole expression. If there is any long string in code, all
textofSTR_CONSTwill be replaced with the text of their parents. This is why your @tonytonov example fails.Hence, we showed that the solution #230 works for quoted arguments, but not for quoted names of the arguments if a long string is present anywhere in the code. Hence, we must find another way of getting
textof long strings.I think we implemented the solution with the parent because there were concerns that extracting text is brittle (#216 (comment)). However, I think there is no way around this. One alternative could be to only replace
textofSTR_CONSTfor strings that actually need a replacement (instead of all), but that is not elegant because long quoted argument names would still cause malformatting.For that reason, I think we can close this issue and repoen #216.
lorenzwalthert commentedon Apr 6, 2018
@tonytonov I just merged #384 into master and I think this problem should now be solved via closing #216. Can you confirm this? The solution should also work for the long example you sent me via email.
tonytonov commentedon Apr 13, 2018
@lorenzwalthert Thanks for the update! I can no longer reproduce the issue using the development version. I assume this will be included into the next CRAN release? (presumably 1.0.2?)
lorenzwalthert commentedon Apr 13, 2018