[vim/vim] serverlist() fails when there is no connection to the X server (PR #21124)

3 views
Skip to first unread message

thinca

unread,
Aug 22, 2026, 9:07:31 AM (4 days ago) Aug 22
to vim/vim, Subscribed

Problem

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.

Why this is a regression

  • It contradicts the documentation. :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.
  • The error was deliberately removed before. Patch 6.0.191: "When no servers are available serverlist() gives an error instead of returning an empty string""Don't give an error message". Patch 6.1.349 did the same for --serverlist when the display cannot be opened.
  • Entry points and backends now disagree. In exactly the situation where the function fails, the --serverlist command line argument still prints an empty list, and the socket backend still returns an empty list.
  • The return type is broken on the failing path. 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

Solution

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.

Tests

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


You can view, comment on, or merge this pull request online at:

  https://github.com/vim/vim/pull/21124

Commit Summary

  • deb6848 serverlist() fails when there is no connection to the X server

File Changes

(4 files)

Patch Links:


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.Message ID: <vim/vim/pull/21124@github.com>

Christian Brabandt

unread,
Aug 23, 2026, 3:21:41 PM (3 days ago) Aug 23
to vim/vim, Subscribed
chrisbra left a comment (vim/vim#21124)

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.Message ID: <vim/vim/pull/21124/c5387988926@github.com>

Reply all
Reply to author
Forward
0 new messages