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

bugfix: Adjust auto import position for shebang #5860

Merged
merged 1 commit into from
Dec 2, 2023

Conversation

jkciesluk
Copy link
Member

fixes #5854

val ammHeaders: List[String] = List("// scala", "// ammonite")

private def adjustShebang(text: String): String =
text.replaceFirst(shebang, s"//$shebang")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Potentially, you could have "#!" somewhere in the code. We should just replace the first line. I think this is already being done in Trees

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think it's that easy, in Trees it is in first line, but here it is after script wrapper. If #! is somewhere in code, we would not get there with skipPrefixesOffset, so it doesn't change anything. The only thing is, if we have using directives first and then shebang, then the import is inserted after it, but I think thats correct behaviour

Copy link
Contributor

@tgodzik tgodzik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, let's merge this, if this fails to fix all the scenarios we'll take a look at them.

@tgodzik tgodzik merged commit 1870e89 into scalameta:main Dec 2, 2023
24 of 25 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Action to add an import to the Scala-CLI script puts it before the shebang.
2 participants