Open axb21 opened 2 years ago
Thanks for reporting! Do you include pprint dependency in your project or only use pprint via worksheets? There was an issue recently about having an incompatible pprint version on classpath versus the one in mdoc. This should be fixed in main.
Do you have a small worksheet example that this fails on? We should be able to print any value including iter.next()
Looks like the ansi escape might be an issue in pprint, but would be great to know what it is caused by, otherwise might be hard to pinpoint.
Thanks for reporting! Do you include pprint dependency in your project or only use pprint via worksheets? There was an issue recently about having an incompatible pprint version on classpath versus the one in mdoc. This should be fixed in main.
It is only pprint via a worksheet. I haven't tested whether the same issue arises in other cases.
Do you have a small worksheet example that this fails on? We should be able to print any value including
iter.next()
Looks like the ansi escape might be an issue in pprint, but would be great to know what it is caused by, otherwise might be hard to pinpoint.
I wish I did, but unfortunately it's a bit complicated. I'm using geotools to parse an ESRI shapefile and retrieve some of the data in it. It's very handy to use worksheets to tinker with these things, which I've done successfully a bunch of times before.
I know some of the properties in this one file that is causing me issues are in Hebrew and the character encoding is UTF-8. It should be fine, and GIS software does not complain about this file, but there seems to be something odd in there that is triggering this error. So far I have not been able to isolate a small example. If I ever manage to do that I'll share it here.
It would be great if you managed to see exactly what this is failing on, it should be a straightforward fix once we know that.
I have reported a similar issue to the
PPrint
library here: https://github.com/com-lihaoyi/PPrint/issues/78I am using scala 2.13.8 on Ubuntu 21.04, writing code in Sublime Text 3 with the LSP and LSP-metals plugins, the latter of which is ultimately responible to the call out to mdoc. As you know metals allows you to make scala worksheets, and will execute the code in those worksheets and show you (pseudo)comments with the result of each line of code.
The gist of the problem is that I am seeing exceptions in the metals log panel, and failure to correctly process worksheets, whenever I include a line of code in the worksheet whose value cannot be correctly handled by
pprint.Renderer
and in turnfansi.Str(_)
. Starting somewhere around here: https://github.com/scalameta/mdoc/blob/3078e6f13d9c808a3bcf106502b8082b0e639d45/runtime/src/main/scala-2/mdoc/internal/document/Printing.scala#L28eventually
pprint.Renderer
is called, which in turn callsfansi.Str(_)
on a string value that is not sanitized. The default behavior of this method is to throw an exception, though the library allows that behavior to be changed. Unfortunately I cannot share the code and data that produce this issue, but below I'll include a typical stack trace. The behavior I observe is: all my code in the worksheet is fine and shows the expected value in a comment after each line of code. However, if I then include a line of code that returns a value (in my case it'siter.next()
), those comments with the values disappear, and a stack trace like the one below appears in the metals log. This does not appear to me to be a metals-specific issue, but one either at the mdoc level or below, which is why I chose to report it here and in the PPrint library repository.A typical stack trace: