]> git.ipfire.org Git - thirdparty/vim.git/commit
runtime(rust): Fix Rust indentation when string contains "if"
authortaylor.fish <contact@taylor.fish>
Wed, 28 Jan 2026 22:04:21 +0000 (22:04 +0000)
committerChristian Brabandt <cb@256bit.org>
Wed, 28 Jan 2026 22:07:16 +0000 (22:07 +0000)
commit663d809194b471ebbdd9e270086c6d0ca53da8fd
treea5118d51c3fe03c67f18c9f64c3608c83a65c535
parent427fa3e1e4b44eb780f3ddae51b49a514530ee64
runtime(rust): Fix Rust indentation when string contains "if"

indent/rust.vim behaves incorrectly when a string literal contains the
substring "if".

For example, in this code:

    let x = "
                motif
    ";
    struct X {
                }

indent/rust.vim thinks that the closing "}" should line up with "motif".

This patch fixes the issue by checking whether the "if" is in a string
literal or comment before considering it to be a match for a subsequent
brace (and also by requiring it to start on a word boundary).

Add an indent test to ensure this does not regress.

closes: #19265

Signed-off-by: taylor.fish <contact@taylor.fish>
Signed-off-by: Christian Brabandt <cb@256bit.org>
runtime/indent/rust.vim
runtime/indent/testdir/rust.in
runtime/indent/testdir/rust.ok