[vim/vim] v9.2.0072 broke try/catch in autocmds (Issue #19535)

10 views
Skip to first unread message

Martin Tournoij

unread,
Feb 28, 2026, 9:25:53 PM (2 days ago) Feb 28
to vim/vim, Subscribed
arp242 created an issue (vim/vim#19535)

I have the following in my vimrc:

vim9script

augroup my-go
	au BufWritePre *.go {
		try | silent undojoin | catch | endtry

		var save = winsaveview()
		exe ':%!gofmt 2>/dev/null || cat /dev/stdin'
		winrestview(save)
	}
augroup end

In Vim v9.2.0071 this works as expected:

./src/vim --clean +'source ~/gofmt.vim' a.go

On write it runs gofmt on the entire buffer to format it. Since Vim v9.2.0072 (1da9d13) this no longer works: it just seems to stop on that try | .. block. I tried splitting that over multiple lines, adding a pattern after the catch, and putting something in the catch block, but none of that seems to help.

Simpler reproducer that doesn't depend on gofmt:

vim9script

augroup my-go
	au BufWritePre *.go {
		try | silent undojoin | catch | endtry

		echoerr 'XXX'
	}
augroup end

You should see that error, but it never happens.

FYI @cuiweixie


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/19535@github.com>

Christian Brabandt

unread,
Mar 1, 2026, 2:23:18 AM (yesterday) Mar 1
to vim/vim, Subscribed
chrisbra left a comment (vim/vim#19535)

The problem seems to be the | being used as separators and no longer being detected. Does it work, if you instead use separate lines for each statement? If yes, I think the fix for this might be this here:

inside_block(exarg_T *eap)
{
    int	i;

    for (i = cstack->cs_idx; i >= 0; --i)
    {
	if (cstack->cs_flags[i] & CSF_BLOCK)
	    return TRUE;
	if (cstack->cs_flags[i] & (CSF_TRY | CSF_WHILE | CSF_FOR))
	    return FALSE;
    }
    return FALSE;
}


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/19535/3979391945@github.com>

Martin Tournoij

unread,
Mar 1, 2026, 7:44:07 AM (yesterday) Mar 1
to vim/vim, Subscribed
arp242 left a comment (vim/vim#19535)

The problem seems to be the ``| being used as separators

Nah, it fails with something like this too (none of the echoerrs show):

vim9script

augroup my-go
    au BufWritePre *.go {
        try
            echoerr 'try'
            silent undojoin
        # or: catch /.*/
        catch
            echoerr 'catch'
        endtry

        echoerr 'XXX'
    }
augroup end


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/19535/3979892661@github.com>

Christian Brabandt

unread,
2:04 PM (7 hours ago) 2:04 PM
to vim/vim, Subscribed

Closed #19535 as completed via 62cf4c2.


Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issue/19535/issue_event/23202866722@github.com>

Reply all
Reply to author
Forward
0 new messages