Since patch 9.2.0818 (#20716), serverlist() gives E240: No connection to the X server when the X11 clientserver backend cannot connect to the X server — for example on a Wayland-only system or with $DISPLAY unset. Before that patch it returned an empty result.
:help serverlist() says "When there are no servers or the information is not available an empty string is returned", and 9.2.0818 did not update it.--serverlist when the display cannot be opened.--serverlist command line argument still prints an empty list, and the socket backend still returns an empty list.rettv is never set, so the result is a Number rather than a String or a List:
silent! let r = serverlist() echo type(r) " 0 (Number), r == 0
Do not give an error when the X server cannot be reached; return an empty string, or an empty List when the "list" option is used.
The "list" option now always results in a List when no server names are available. That is the type inconsistency 9.2.0818 set out to fix — serverlist({'list': 1}) returning a String — and it is fixed for every backend, including a build without +clientserver.
Test_clientserver_serverlist_without_x11() now checks that a child Vim without $DISPLAY returns '' from serverlist() and [] from serverlist(#{list: v:true}). It fails before the fix and passes after it:
# before
Found errors in Test_clientserver_serverlist_without_x11():
... line 36: Expected 0 but got 1
# after
Executed 1 test
The child process wraps the calls in a try/catch because an error in a sourced script only aborts the failing command: without it the assertion is never reached, v:errors stays empty and the test passes even when serverlist() fails (verified: exit code 0).
The catch /E240:/ workaround that 9.2.0818 added to Test_remote_serverlist() in test_vim9_builtin.vim is no longer needed and is removed, so that test checks the return types again.
🤖 Generated with Claude Code
https://github.com/vim/vim/pull/21124
(4 files)
—
Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications, keep track of coding agent tasks and review pull requests on the go with GitHub Mobile for iOS and Android. Download it today!
You are receiving this because you are subscribed to this thread.![]()
thanks
—
Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications, keep track of coding agent tasks and review pull requests on the go with GitHub Mobile for iOS and Android. Download it today!
You are receiving this because you are subscribed to this thread.![]()