diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/nvim/auevents.lua | 2 | ||||
-rw-r--r-- | src/nvim/fileio.c | 1 | ||||
-rw-r--r-- | src/nvim/option.c | 10 | ||||
-rw-r--r-- | src/nvim/options.lua | 2 | ||||
-rw-r--r-- | src/nvim/os/signal.c | 23 | ||||
-rw-r--r-- | src/nvim/terminal.c | 11 |
6 files changed, 34 insertions, 15 deletions
diff --git a/src/nvim/auevents.lua b/src/nvim/auevents.lua index 3cffd66dee..cc0ed0f587 100644 --- a/src/nvim/auevents.lua +++ b/src/nvim/auevents.lua @@ -74,6 +74,7 @@ return { 'SessionLoadPost', -- after loading a session file 'ShellCmdPost', -- after ":!cmd" 'ShellFilterPost', -- after ":1,2!cmd", ":w !cmd", ":r !cmd". + 'Signal', -- after nvim process received a signal 'SourceCmd', -- sourcing a Vim script using command 'SourcePre', -- before sourcing a Vim script 'SpellFileMissing', -- spell file missing @@ -115,6 +116,7 @@ return { -- syntax file nvim_specific = { DirChanged=true, + Signal=true, TabClosed=true, TabNew=true, TabNewEntered=true, diff --git a/src/nvim/fileio.c b/src/nvim/fileio.c index ba154ea36a..6356290b9c 100644 --- a/src/nvim/fileio.c +++ b/src/nvim/fileio.c @@ -6917,6 +6917,7 @@ static bool apply_autocmds_group(event_T event, char_u *fname, char_u *fname_io, || event == EVENT_REMOTEREPLY || event == EVENT_SPELLFILEMISSING || event == EVENT_SYNTAX + || event == EVENT_SIGNAL || event == EVENT_TABCLOSED) { fname = vim_strsave(fname); } else { diff --git a/src/nvim/option.c b/src/nvim/option.c index c57e6649bb..3914e020b1 100644 --- a/src/nvim/option.c +++ b/src/nvim/option.c @@ -4240,8 +4240,7 @@ static char *set_num_option(int opt_idx, char_u *varp, long value, } else if (pp == &curbuf->b_p_channel || pp == &p_channel) { errmsg = e_invarg; } else if (pp == &curbuf->b_p_scbk || pp == &p_scbk) { - if (value < -1 || value > SB_MAX - || (value != -1 && opt_flags == OPT_LOCAL && !curbuf->terminal)) { + if (value < -1 || value > SB_MAX) { errmsg = e_invarg; } } else if (pp == &curbuf->b_p_sw || pp == &p_sw) { @@ -4435,11 +4434,6 @@ static char *set_num_option(int opt_idx, char_u *varp, long value, *(long *)get_varp_scope(&(options[opt_idx]), OPT_GLOBAL) = *pp; } - if (pp == &curbuf->b_p_scbk && !curbuf->terminal) { - // Normal buffer: reset local 'scrollback' after updating the global value. - curbuf->b_p_scbk = -1; - } - options[opt_idx].flags |= P_WAS_SET; // Don't do this while starting up, failure or recursively. @@ -5862,7 +5856,7 @@ void buf_copy_options(buf_T *buf, int flags) buf->b_p_ai = p_ai; buf->b_p_ai_nopaste = p_ai_nopaste; buf->b_p_sw = p_sw; - buf->b_p_scbk = -1; + buf->b_p_scbk = p_scbk; buf->b_p_tw = p_tw; buf->b_p_tw_nopaste = p_tw_nopaste; buf->b_p_tw_nobin = p_tw_nobin; diff --git a/src/nvim/options.lua b/src/nvim/options.lua index 222ec5457b..127c15dd5a 100644 --- a/src/nvim/options.lua +++ b/src/nvim/options.lua @@ -1930,7 +1930,7 @@ return { vi_def=true, varname='p_scbk', redraw={'current_buffer'}, - defaults={if_true={vi=10000}} + defaults={if_true={vi=-1}} }, { full_name='scrollbind', abbreviation='scb', diff --git a/src/nvim/os/signal.c b/src/nvim/os/signal.c index fc7f9cefd1..20f68233e7 100644 --- a/src/nvim/os/signal.c +++ b/src/nvim/os/signal.c @@ -15,6 +15,7 @@ #include "nvim/globals.h" #include "nvim/memline.h" #include "nvim/eval.h" +#include "nvim/fileio.h" #include "nvim/main.h" #include "nvim/memory.h" #include "nvim/misc1.h" @@ -22,7 +23,7 @@ #include "nvim/os/signal.h" #include "nvim/event/loop.h" -static SignalWatcher spipe, shup, squit, sterm; +static SignalWatcher spipe, shup, squit, sterm, susr1; #ifdef SIGPWR static SignalWatcher spwr; #endif @@ -61,6 +62,10 @@ void signal_init(void) signal_watcher_init(&main_loop, &spwr, NULL); signal_watcher_start(&spwr, on_signal, SIGPWR); #endif +#ifdef SIGUSR1 + signal_watcher_init(&main_loop, &susr1, NULL); + signal_watcher_start(&susr1, on_signal, SIGUSR1); +#endif } void signal_teardown(void) @@ -73,6 +78,9 @@ void signal_teardown(void) #ifdef SIGPWR signal_watcher_close(&spwr, NULL); #endif +#ifdef SIGUSR1 + signal_watcher_close(&susr1, NULL); +#endif } void signal_stop(void) @@ -84,6 +92,9 @@ void signal_stop(void) #ifdef SIGPWR signal_watcher_stop(&spwr); #endif +#ifdef SIGUSR1 + signal_watcher_stop(&susr1); +#endif } void signal_reject_deadly(void) @@ -115,6 +126,10 @@ static char * signal_name(int signum) #endif case SIGHUP: return "SIGHUP"; +#ifdef SIGUSR1 + case SIGUSR1: + return "SIGUSR1"; +#endif default: return "Unknown"; } @@ -162,6 +177,12 @@ static void on_signal(SignalWatcher *handle, int signum, void *data) deadly_signal(signum); } break; +#ifdef SIGUSR1 + case SIGUSR1: + apply_autocmds(EVENT_SIGNAL, (char_u *)"SIGUSR1", curbuf->b_fname, true, + curbuf); + break; +#endif default: ELOG("invalid signal: %d", signum); break; diff --git a/src/nvim/terminal.c b/src/nvim/terminal.c index 33050ac642..5d8c29a5ad 100644 --- a/src/nvim/terminal.c +++ b/src/nvim/terminal.c @@ -236,7 +236,7 @@ Terminal *terminal_open(TerminalOptions opts) // Default settings for terminal buffers curbuf->b_p_ma = false; // 'nomodifiable' curbuf->b_p_ul = -1; // 'undolevels' - curbuf->b_p_scbk = p_scbk; // 'scrollback' + curbuf->b_p_scbk = (p_scbk == -1) ? 10000 : MAX(1, p_scbk); // 'scrollback' curbuf->b_p_tw = 0; // 'textwidth' set_option_value("wrap", false, NULL, OPT_LOCAL); set_option_value("list", false, NULL, OPT_LOCAL); @@ -249,8 +249,7 @@ Terminal *terminal_open(TerminalOptions opts) apply_autocmds(EVENT_TERMOPEN, NULL, NULL, false, curbuf); // Configure the scrollback buffer. - rv->sb_size = curbuf->b_p_scbk < 0 - ? SB_MAX : (size_t)MAX(1, curbuf->b_p_scbk); + rv->sb_size = (size_t)curbuf->b_p_scbk; rv->sb_buffer = xmalloc(sizeof(ScrollbackLine *) * rv->sb_size); if (!true_color) { @@ -1162,8 +1161,10 @@ static void refresh_size(Terminal *term, buf_T *buf) /// Adjusts scrollback storage after 'scrollback' option changed. static void on_scrollback_option_changed(Terminal *term, buf_T *buf) { - const size_t scbk = curbuf->b_p_scbk < 0 - ? SB_MAX : (size_t)MAX(1, curbuf->b_p_scbk); + if (buf->b_p_scbk < 1) { + buf->b_p_scbk = SB_MAX; + } + const size_t scbk = (size_t)buf->b_p_scbk; assert(term->sb_current < SIZE_MAX); if (term->sb_pending > 0) { // Pending rows must be processed first. abort(); |