Page MenuHomePhabricator

Gerrit editor replaces tabs with spaces
Closed, ResolvedPublic

Description

I can't for the life of me understand how to tell gerrit that I want to use tabs for indentation when editing files from the UI. These are my current preferences:

image.png (838×937 px, 66 KB)

Yet, if I open any file in edit mode (recent example), put my cursor at the end of a line and hit enter, gerrit will indent the next line with 10 spaces (not tabs). Clearly I must be missing something?!

Event Timeline

Reedy renamed this task from Closing brace replaces leading tabs with spaces to Gerrit likes to replace tabs with spaces.Jan 24 2024, 7:57 PM
Reedy updated the task description. (Show Details)

I'm suspecting this is because "Indent with tabs" wasn't checked/enabled...

And I imagine I might not be the only one. Do we have a way to change default settings? Considering we mostly use tabs, having it enabled by default probably makes some sense...

hashar added subscribers: Paladox, hashar.

When looking at the upstream bug tracker, I found 40006891 which in turns point to our T168590: Change Gerrit's default indentation to tabs. @Paladox added that Indent With Tab preference. The default is false and is hardwired in both the Java backend and the Javascript frontend. That can be changed from the user's Edit Preferences.

The preference applies to anything being edited, I guess the edit window might benefit from having an easy way to switch back and forth, or maybe some heuristic can be implemented to detect the type of indentation being used and automatically set the pref for the currently edited file.

I am not sure what to do with that task though :-\

I'm not sure either. I know we've had a few upgrades recently, and I'm not sure if there's been some different handling in those versions, and as such, the behaviour in the videos seems to be new/worse.

I'm suspecting me changing my preference fixes most of it, but...

I think a potential fix is detecting if there's tabs in the file and using that but also adding "auto" to the preference. So the preference will indicated what to do whether to check the file or force use of spaces/tabs.

Seems the REST API is "indent_with_tabs" so it's true / false. So we would have to either create a new option to allow the three options above or if indent_with_tabs is true then always indent with tabs or if it's false check content for tabs otherwise use spaces.

hashar renamed this task from Gerrit likes to replace tabs with spaces to Gerrit editor replaces tabs with spaces.Jan 26 2024, 3:22 PM

@Paladox you are really a jewel to the wikis movements. Thank you!

The fix is backported to 3.11 by https://gerrit-review.googlesource.com/c/gerrit/+/463081

@Paladox you are really a jewel to the wikis movements. Thank you!

The fix is backported to 3.11 by https://gerrit-review.googlesource.com/c/gerrit/+/463081

merged in 3.11 now.

hashar edited projects, added Gerrit (Gerrit 3.10); removed Gerrit.
hashar moved this task from Patch merged upstream to Patch released upstream on the Upstream board.

The fix has been released in 3.10.5 and 3.11.2

@Reedy & @Winston_Sung I have upgraded to Gerrit 3.10.6 some minutes ago, that supposedly fixes the issue.

Tested and confirmed the bug is fixed.