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

"editor: format selections" should format the current line if there's no selection #22816

Open
1 task done
hferreiro opened this issue Jan 8, 2025 · 1 comment
Open
1 task done
Labels
bite-size small issues enhancement [core label] tooling An umbrella label for language tools, linters, formatters, etc

Comments

@hferreiro
Copy link
Contributor

Check for existing issues

  • Completed

Describe the feature

When calling "editor: format selections" when there is nothing selected, the current line should be formatted. This is the behavior of VSCode.

Zed Version and System Specs

Zed: v0.167.2 (Zed)
OS: macOS 15.2.0
Memory: 32 GiB
Architecture: aarch64

If applicable, add mockups / screenshots to help present your vision of the feature

No response

@hferreiro hferreiro added admin read Pending admin review enhancement [core label] triage Maintainer needs to classify the issue labels Jan 8, 2025
@notpeter notpeter added tooling An umbrella label for language tools, linters, formatters, etc bite-size small issues and removed triage Maintainer needs to classify the issue admin read Pending admin review labels Jan 8, 2025
@spotikhanov
Copy link
Contributor

Tried to look at the issue, noticed a few things here, also left a screen record attachment:

1 — selected line 14, clicked "Format selection" in the context menu, line 11 is formatted (timestamps 00:00-00:06).

2 — line 14 is unformatted again, clicked "Format selection" from the action menu, as the action is the same as before, line 11 is formatted (timestamps 00:07-00:11). Two things bother me here:

2.1 — why line 11 is formatted, when it's not selected? is this expected or should be considered a bug?

2.2 — it seems like @hferreiro gets other results, from the description it seems like the specific line is not formatted in his case (or maybe @hferreiro means the whole buffer is formatted, not sure). Maybe it depends on the language server. Steps to reproduce may help.

3 — some language servers do not support range formatting (timestamps 00:15-00:24), so nothing happens, the error is logged. Should we try to remove the option "Format selection" from the context menu and the actions menu in this case? not sure if we could get this info from the language server, but maybe

range.selections.mp4

Hi, @notpeter, I could try to resolve this issue if we discuss what needs to be changed here based on the questions above

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bite-size small issues enhancement [core label] tooling An umbrella label for language tools, linters, formatters, etc
Projects
None yet
Development

No branches or pull requests

3 participants