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

Bug: Incorrect Formatting #744

Closed
tmillr opened this issue Aug 14, 2023 · 1 comment · Fixed by #753
Closed

Bug: Incorrect Formatting #744

tmillr opened this issue Aug 14, 2023 · 1 comment · Fixed by #753
Labels
bug Something isn't working

Comments

@tmillr
Copy link

tmillr commented Aug 14, 2023

Formatting bug or incorrect formatting with stylua@v0.18.1.

Diff

:w !~/stylua -s -c --verify -                                                                                                                                          
Diff in stdin:                                                                                                                                                         
1        |-             if tabnr ~= finaltab then                                                                                                                      
2        |-                                                                                                                                                            
3        |-        stack:push '%T'                                                                                                                                     
4        |-             end                                                                                                                                            
    1    |+if tabnr ~= finaltab then                                                                                                                                   
    2    |+ stack:push '%T' end                                                                                                                                        
                                                                                                                                                                       
shell returned 1  

Formatted Using

stylua -s -c --verify -

Note

Using --verify doesn't appear to change anything, but removing -s makes the bug disappear.


Original (this was taken out of a larger file):

		if tabnr ~= finaltab then
			
        stack:push '%T'
		end

Formatted

if tabnr ~= finaltab then
 stack:push '%T' end

If this^ is then formatted again (or rather, in-turn) it becomes:

if tabnr ~= finaltab then stack:push '%T' end

Config

column_width = 78
line_endings = "Unix"
indent_type = "Spaces"
indent_width = 4
quote_style = "AutoPreferSingle"
call_parentheses = "None"
collapse_simple_statement = "Always"
@tmillr
Copy link
Author

tmillr commented Aug 14, 2023

It seems that the issue persists even if all the tabs in the original are replaced with spaces (e.g. 4 spaces each) before formatting.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants