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

Handle block comments with text on the same line as <# #> #2848

Merged

Conversation

TylerLeonhardt
Copy link
Member

@TylerLeonhardt TylerLeonhardt commented Jul 31, 2020

PR Summary

Fixes #2845

This will better support block comments with stuff on the line:

<# foo
bar
baz #>

and also make sure that saving doesn't mess up the style it previously used.

PR Checklist

Note: Tick the boxes below that apply to this pull request by putting an x between the square brackets.
Please mark anything not applicable to this PR NA.

  • PR has a meaningful title
  • Summarized changes
  • PR has tests
  • This PR is ready to merge and is not work in progress
    • If the PR is work in progress, please add the prefix WIP: to the beginning of the title and remove the prefix when the PR is ready

@TylerLeonhardt TylerLeonhardt requested a review from rjmholt July 31, 2020 17:32
@ghost ghost added Area-Notebooks Issue-Bug A bug to squash. labels Jul 31, 2020
@TylerLeonhardt TylerLeonhardt changed the title Handle block comments better Handle block comments with text on the same line as <# #> Jul 31, 2020
src/features/PowerShellNotebooks.ts Outdated Show resolved Hide resolved
}
}
}

await vscode.workspace.fs.writeFile(targetResource, new TextEncoder().encode(retArr.join("\n")));
await vscode.workspace.fs.writeFile(targetResource, new TextEncoder().encode(retArr.join(EOL)));
Copy link
Contributor

Choose a reason for hiding this comment

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

This will replace newlines in a script when it changes operating systems. For example, if we have a script checked in to git and you edit it, then I edit it, I'll change all the newlines in it. Harder to implement an alternative, but something we should aim not to do -- I wouldn't want my text editor silently reencoding line endings as a side-effect of an unrelated operation. I think worth documenting and/or opening a new issue for

Copy link
Member Author

Choose a reason for hiding this comment

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

So to solve this, I included metadata at the document level that says which line ending that file uses

@@ -78,7 +77,7 @@ function CreateCell(cellKind: vscode.CellKind, source: string[], metadata: IPowe
cellKind,
language: cellKind === vscode.CellKind.Markdown ? "markdown" : "powershell",
outputs: [],
source: source.join(EOL),
source: source.join("\n"),
Copy link
Member Author

Choose a reason for hiding this comment

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

This is only used in the rendering of notebooks so \n is totally fine.

@TylerLeonhardt
Copy link
Member Author

@rjmholt I believe this is good to go.

@TylerLeonhardt TylerLeonhardt merged commit 526fb22 into PowerShell:master Aug 3, 2020
@TylerLeonhardt TylerLeonhardt deleted the handle-block-comments-better branch August 3, 2020 17:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Issue-Bug A bug to squash.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Notebook Mode: The comment block is not recognized as a Markdown block
2 participants