mirror of
https://github.com/neovim/neovim.git
synced 2025-11-23 10:36:29 +00:00
feat(server): set $NVIM, unset $NVIM_LISTEN_ADDRESS #11009
PROBLEM
------------------------------------------------------------------------
$NVIM_LISTEN_ADDRESS has conflicting purposes as both a parameter ("the
current process should listen on this address") and a descriptor ("the
current process is a child of this address").
This contradiction means the presence of NVIM_LISTEN_ADDRESS is
ambiguous, so child Nvim always tries to listen on its _parent's_
socket. This is the cause of lots of "Failed to start server" spam in
our test/CI logs:
WARN 2022-04-30… server_start:154: Failed to start server: address already in use: \\.\pipe\nvim-4480-0
WARN 2022-04-30… server_start:154: Failed to start server: address already in use: \\.\pipe\nvim-2168-0
SOLUTION
------------------------------------------------------------------------
1. Set $NVIM to the parent v:servername, *only* in child processes.
- Now the correct way to detect a "parent" Nvim is to check for $NVIM.
2. Do NOT set $NVIM_LISTEN_ADDRESS in child processes.
3. On startup if $NVIM_LISTEN_ADDRESS exists, unset it immediately after
server init.
4. Open a channel to parent automatically, expose it as v:parent.
Fixes #3118
Fixes #6764
Fixes #9336
Ref https://github.com/neovim/neovim/pull/8247#issuecomment-380275696
Ref #8696
This commit is contained in:
@@ -179,6 +179,13 @@ static void term_output_callback(const char *s, size_t len, void *user_data)
|
||||
|
||||
// public API {{{
|
||||
|
||||
/// Initializes terminal properties, and triggers TermOpen.
|
||||
///
|
||||
/// The PTY process (TerminalOptions.data) was already started by termopen(),
|
||||
/// via ex_terminal() or the term:// BufReadCmd.
|
||||
///
|
||||
/// @param buf Buffer used for presentation of the terminal.
|
||||
/// @param opts PTY process channel, various terminal properties and callbacks.
|
||||
Terminal *terminal_open(buf_T *buf, TerminalOptions opts)
|
||||
{
|
||||
// Create a new terminal instance and configure it
|
||||
@@ -374,6 +381,7 @@ void terminal_check_size(Terminal *term)
|
||||
invalidate_terminal(term, -1, -1);
|
||||
}
|
||||
|
||||
/// Implements TERM_FOCUS mode. :help Terminal-mode
|
||||
void terminal_enter(void)
|
||||
{
|
||||
buf_T *buf = curbuf;
|
||||
@@ -502,6 +510,7 @@ static int terminal_check(VimState *state)
|
||||
return 1;
|
||||
}
|
||||
|
||||
/// Processes one char of terminal-mode input.
|
||||
static int terminal_execute(VimState *state, int key)
|
||||
{
|
||||
TerminalState *s = (TerminalState *)state;
|
||||
@@ -1448,7 +1457,8 @@ static void refresh_terminal(Terminal *term)
|
||||
long ml_added = buf->b_ml.ml_line_count - ml_before;
|
||||
adjust_topline(term, buf, ml_added);
|
||||
}
|
||||
// Calls refresh_terminal() on all invalidated_terminals.
|
||||
|
||||
/// Calls refresh_terminal() on all invalidated_terminals.
|
||||
static void refresh_timer_cb(TimeWatcher *watcher, void *data)
|
||||
{
|
||||
refresh_pending = false;
|
||||
|
||||
Reference in New Issue
Block a user