You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The new Rewrap command from #17909 produces a line that soft-wraps in the editor when using tabs:
The above is produced with preferred_line_length=80 soft_wrap=preferred_line_length (and I assume tab_size=4 by default for Go) and after invoking Rewrap.
Golang always uses tabs for indentation, so the issue is most relevant for Go code.
If applicable, add mockups / screenshots to help explain present your vision of the feature
Looking at the code, Rewrap clearly deals in characters; current_line.len() + word.len() >= wrap_column condition doesn't account for tab characters.
An easy fix would be to count the tabs and subtract (tab_count * (tab-size - 1)) from the left-hand side of that comparison. Of course, expanding tabs correctly would be even better, in case those are mixed with spaces.
(Also I'm wondering that Rewrap has to implement its own wrapping. This seems perilous. Zed already has code to wrap text correctly somewhere, I wish we could reuse that.)
If applicable, attach your Zed.log file to this issue.
Zed.log
The text was updated successfully, but these errors were encountered:
Check for existing issues
Describe the bug / provide steps to reproduce it
The new Rewrap command from #17909 produces a line that soft-wraps in the editor when using tabs:
The above is produced with
preferred_line_length=80 soft_wrap=preferred_line_length
(and I assumetab_size=4
by default for Go) and after invoking Rewrap.Golang always uses tabs for indentation, so the issue is most relevant for Go code.
Environment
Zed: v0.155.2 (Zed)
OS: macOS 14.1.1
Memory: 24 GiB
Architecture: aarch64
If applicable, add mockups / screenshots to help explain present your vision of the feature
Looking at the code, Rewrap clearly deals in characters;
current_line.len() + word.len() >= wrap_column
condition doesn't account for tab characters.An easy fix would be to count the tabs and subtract (tab_count * (tab-size - 1)) from the left-hand side of that comparison. Of course, expanding tabs correctly would be even better, in case those are mixed with spaces.
(Also I'm wondering that Rewrap has to implement its own wrapping. This seems perilous. Zed already has code to wrap text correctly somewhere, I wish we could reuse that.)
If applicable, attach your Zed.log file to this issue.
Zed.log
The text was updated successfully, but these errors were encountered: