Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Worksheet mode adds spaces into multiline strings #722

Open
Sporarum opened this issue Dec 8, 2022 · 7 comments
Open

Worksheet mode adds spaces into multiline strings #722

Sporarum opened this issue Dec 8, 2022 · 7 comments

Comments

@Sporarum
Copy link

Sporarum commented Dec 8, 2022

Describe the bug

The worksheet seems to tabulate the inside of multi-line strings, resulting in unexpected spaces

  1. Metals: Create Worksheet
  2. Write
val s = """
""".length
  1. Worksheet adds comment: // : Int = 5

Expected behavior

Should not add extra characters inside multiline strings

The example should add the comment //: Int = 1

Operating system

Windows

Editor/Extension

VS Code

Version of Metals

0.11.9 ?

Extra context or search terms

No response

@Sporarum
Copy link
Author

Sporarum commented Dec 8, 2022

I wasn't sure how to find the version of metals, but VSCode seems to think it is up to date
I put 0.11.9 as it was the default and what is present at https://scalameta.org/metals/docs/

But the changelog tab of the Extension: Scala (Metals) page in VSCode shows v1.20.0 as the latest

@tgodzik
Copy link
Contributor

tgodzik commented Dec 8, 2022

Thanks for reporting! I am not sure if we can fix it properly. The way it's currently done is that we wrap the code in additional objects and in order to make sure that Scala 3 works properly we add indentation. Maybe we could do no indentation for the wrapper and then would the indentation work? Something like the below should probably work:

class wrapped{
object A:
   def foo
A.foo
}

The fixed needs to be done in mdoc

@tgodzik tgodzik transferred this issue from scalameta/metals Dec 8, 2022
@Sporarum
Copy link
Author

In the meantime, we should at least emit a warning saying something like "Please use the pattern with | and .stripMargin"
Because this is very surprising behavior, especially given Worksheets might be the first experience people have of Scala

@Sporarum
Copy link
Author

Oh and thank you for your reply ^^"

@kubukoz
Copy link

kubukoz commented Jan 26, 2024

just saw it, had the most fun trying to recognize whether I broke my keyboard, filesystem, or switched to some strange newline separator in VSCode 😅

@kubukoz
Copy link

kubukoz commented Jan 26, 2024

BTW. @Sporarum you meant it should print 1, right? That's what I get in the REPL. The newline counts.

@Sporarum
Copy link
Author

Oh yes of course, I'll edit the description

Was: "The example should add the comment //: Int = 0"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants