Skip to content

Format cell adds blank line at the end #18121

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

Closed
memeplex opened this issue Dec 4, 2021 · 5 comments
Closed

Format cell adds blank line at the end #18121

memeplex opened this issue Dec 4, 2021 · 5 comments

Comments

@memeplex
Copy link

memeplex commented Dec 4, 2021

Environment data

  • VS Code version: 1.61.2
  • Jupyter Extension version (available under the Extensions sidebar): v2021.9.1101343141
  • Python Extension version (available under the Extensions sidebar): v2021.11.1422169775
  • OS (Windows | Mac | Linux distro) and version: macOS Big Sur
  • Python and/or Anaconda version: 3.9.7
  • Type of virtual environment used (N/A | venv | virtualenv | conda | ...): venv
  • Jupyter server running: Local

Expected behaviour

If I format a cell using black no blank line is added at the end of the cell.

Actual behaviour

A blank line is added at the end of the cell.

Steps to reproduce:

[NOTE: Self-contained, minimal reproducing code samples are extremely helpful and will expedite addressing your issue]

  1. Configure black as formatter.
  2. Create a note with a cell with x = 1 as content.
  3. From the context menu for the cell, select Format cell.
@memeplex
Copy link
Author

memeplex commented Dec 4, 2021

Maybe it's not that a blank line is added at the end but that a newline is added to the last line. Anyway, that might be ok for a python file but it's undesirable for a cell, it's a lot of wasted space having what, at least visually, is a blank line in each cell of a notebook.

@rchiodo rchiodo transferred this issue from microsoft/vscode-jupyter Dec 6, 2021
@github-actions github-actions bot added the triage-needed Needs assignment to the proper sub-team label Dec 6, 2021
@rchiodo
Copy link

rchiodo commented Dec 6, 2021

Cell formatting is actually handled by the python extension (cells are considered python documents). Transferring issue there.

@memeplex
Copy link
Author

memeplex commented Dec 6, 2021

I don't think that approach would work OOTB, I've seen problems with it in Jupyter Lab extensions as well, cells have their own quirks, for example you don't want a newline at the end of a cell.

@memeplex
Copy link
Author

memeplex commented Dec 6, 2021

Perhaps one should use a formatter that supports selection format, instead of black (as in my case).

@karthiknadig
Copy link
Member

This should be handled when we move formatting over LSP. Closing in favor of #17918

@karthiknadig karthiknadig removed the triage-needed Needs assignment to the proper sub-team label Dec 6, 2021
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jan 6, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants