[vim/vim] The enum indentation is wrong in Vim9 script (Issue #16289)

11 views
Skip to first unread message

h_east

unread,
Dec 24, 2024, 1:27:21 AM12/24/24
to vim/vim, Subscribed

Steps to reproduce

  1. Prepare the following file (e.vim).
vim9script

enum Color
White,
Red,
Black
endenum

var co: Color = Color.Black
echo "co: " .. string(co)

# vim:ts=4 sw=0
  1. Run Vim.
$ vim --clean e.vim
  1. Format(re-indent) the entire file.
ggVG=

Result:

vim9script

enum Color
    White,
        Red,             <--- Wrong
        Black            <--- Wrong
endenum

var co: Color = Color.Black
echo "co: " .. string(co)

# vim:et ts=4 sw=0

Expected behaviour

vim9script

enum Color
    White,
    Red,
    Black
endenum

var co: Color = Color.Black
echo "co: " .. string(co)

# vim:et ts=4 sw=0

Version of Vim

9.1.0955

Environment

Ubuntu 22.04.5 LTS

Logs and stack traces

none


Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issues/16289@github.com>

Jim Zhou

unread,
Dec 24, 2024, 4:54:50 AM12/24/24
to vim/vim, Subscribed

Not only for Vim9 Script. Reindent also doesn't work for python as I tested.

Reproduction

  1. Prepare the test.py
 def test_indent(a, b):
     if a > b:
         print(f"{a} is greater than {b}")
         result = a - b
     else:
         print(f"{b} is greater than or equal to {a}")
         result = b - a
 
     for i in range(result):
         if i % 2 == 0:
             print(f"Even number: {i}")
         else:
             print(f"Odd number: {i}")
 
     return result
 
 x = 10
 y = 5
 print(f"Result of test_indent: {test_indent(x, y)}")
  1. Follow @h-east 's steps
  2. Result (Incorrect)
def test_indent(a, b):
        if a > b:
        print(f"{a} is greater than {b}")
        result = a - b
        else:
        print(f"{b} is greater than or equal to {a}")
        result = b - a

        for i in range(result):
                if i % 2 == 0:
                print(f"Even number: {i}")
                else:
                print(f"Odd number: {i}")

                return result

                x = 10
                y = 5
                print(f"Result of test_indent: {test_indent(x, y)}")


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issues/16289/2560922543@github.com>

Christian Brabandt

unread,
Dec 24, 2024, 5:08:59 AM12/24/24
to vim/vim, Subscribed

But that is a different issue, since indentation is filetype specific


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issues/16289/2560938280@github.com>

Jim Zhou

unread,
Dec 24, 2024, 5:55:10 AM12/24/24
to vim/vim, Subscribed

But that is a different issue, since indentation is filetype specific

The python issue wasn't an issue. It's my fault. I compiled and ran vim in macOS without noticing that defaults.vim is stored at different directory. I'm sorry for the misleading.


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issues/16289/2560985102@github.com>

Christian Brabandt

unread,
Dec 26, 2024, 4:39:19 AM12/26/24
to vim/vim, Subscribed

Closed #16289 as completed via 6d2efd4.


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issue/16289/issue_event/15764607757@github.com>

Reply all
Reply to author
Forward
0 new messages