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

ruff.applyFormat now formats an entire notebook document #11493

Merged
merged 1 commit into from
May 22, 2024

Conversation

snowsignal
Copy link
Contributor

Summary

Previously, ruff.applyFormat, seen in VS Code as the command Ruff: Format Document, would only format the currently active notebook cell inside a notebook document. This PR makes ruff.applyFormat format the entire notebook document at once, operating on each code cell in order.

Test Plan

  1. Open a notebook document that has multiple unformatted code cells.
  2. Run Ruff: Format Document through the Command Palette (Ctrl/Cmd+Shift+P by default)
  3. Observe that all code cells in the notebook have been formatted.

@snowsignal snowsignal added notebook Related to (Jupyter) notebooks server Related to the LSP server labels May 22, 2024
@snowsignal snowsignal force-pushed the jane/server/notebook/format/all-cells-cmd branch from f31f4d2 to 4421339 Compare May 22, 2024 09:33
Copy link
Contributor

ruff-ecosystem results

Linter (stable)

✅ ecosystem check detected no linter changes.

Linter (preview)

✅ ecosystem check detected no linter changes.

@snowsignal snowsignal merged commit 3cb2e67 into main May 22, 2024
19 checks passed
@snowsignal snowsignal deleted the jane/server/notebook/format/all-cells-cmd branch May 22, 2024 16:02
pub(super) fn format_full_document(snapshot: &DocumentSnapshot) -> Result<Fixes> {
let mut fixes = Fixes::default();

if let Some(notebook) = snapshot.query().as_notebook() {
Copy link
Member

Choose a reason for hiding this comment

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

Nit: Would it make sense to store the result of snapshot.query() in a variable. It's used in multiple places and feels fairly repetitive.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
notebook Related to (Jupyter) notebooks server Related to the LSP server
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants