diff options
| -rw-r--r-- | src/nvim/buffer_defs.h | 20 | ||||
| -rw-r--r-- | src/nvim/normal.c | 8 | ||||
| -rw-r--r-- | src/nvim/terminal.c | 8 | ||||
| -rw-r--r-- | src/nvim/undo.c | 7 | 
4 files changed, 15 insertions, 28 deletions
| diff --git a/src/nvim/buffer_defs.h b/src/nvim/buffer_defs.h index 9c5c7859ff..154df0eff0 100644 --- a/src/nvim/buffer_defs.h +++ b/src/nvim/buffer_defs.h @@ -36,7 +36,7 @@ typedef struct {  // for Map(K, V)  #include "nvim/map.h" -#define MODIFIABLE(buf) (!buf->terminal && buf->b_p_ma) +#define MODIFIABLE(buf) (buf->b_p_ma)  /*   * Flags for w_valid. @@ -91,32 +91,22 @@ typedef struct frame_S frame_T;  // for struct memline (it needs memfile_T)  #include "nvim/memline_defs.h" -  // for struct memfile, bhdr_T, blocknr_T... (it needs buf_T)  #include "nvim/memfile_defs.h" -/* - * This is here because regexp_defs.h needs win_T and buf_T. regprog_T is - * used below. - */ +// for regprog_T. Needs win_T and buf_T.  #include "nvim/regexp_defs.h" - -// for  synstate_T (needs reg_extmatch_T, win_T and buf_T) +// for synstate_T (needs reg_extmatch_T, win_T, buf_T)  #include "nvim/syntax_defs.h" -  // for signlist_T  #include "nvim/sign_defs.h" -  // for bufhl_*_T  #include "nvim/bufhl_defs.h"  typedef Map(linenr_T, bufhl_vec_T) bufhl_info_T; -// for FileID -#include "nvim/os/fs_defs.h" - -// for Terminal -#include "nvim/terminal.h" +#include "nvim/os/fs_defs.h"    // for FileID +#include "nvim/terminal.h"      // for Terminal  /*   * The taggy struct is used to store the information about a :tag command. diff --git a/src/nvim/normal.c b/src/nvim/normal.c index 756053dc73..e79939ab10 100644 --- a/src/nvim/normal.c +++ b/src/nvim/normal.c @@ -7435,12 +7435,10 @@ static void nv_edit(cmdarg_T *cap)    /* in Visual mode and after an operator "a" and "i" are for text objects */    else if ((cap->cmdchar == 'a' || cap->cmdchar == 'i') -           && (cap->oap->op_type != OP_NOP -               || VIsual_active -               )) { +           && (cap->oap->op_type != OP_NOP || VIsual_active)) {      nv_object(cap); -  } else if (!curbuf->b_p_ma && !p_im) { -    /* Only give this error when 'insertmode' is off. */ +  } else if (!curbuf->b_p_ma && !p_im && !curbuf->terminal) { +    // Only give this error when 'insertmode' is off.      EMSG(_(e_modifiable));      clearop(cap->oap);    } else if (!checkclearopq(cap->oap)) { diff --git a/src/nvim/terminal.c b/src/nvim/terminal.c index 02500a407c..e56b5da183 100644 --- a/src/nvim/terminal.c +++ b/src/nvim/terminal.c @@ -237,12 +237,16 @@ Terminal *terminal_open(TerminalOptions opts)    rv->invalid_end = opts.height;    refresh_screen(rv, curbuf);    set_option_value((uint8_t *)"buftype", 0, (uint8_t *)"terminal", OPT_LOCAL); +    // some sane settings for terminal buffers +  curbuf->b_p_ma = false;   // 'nomodifiable' +  curbuf->b_p_ul = -1;      // disable undo    set_option_value((uint8_t *)"wrap", false, NULL, OPT_LOCAL);    set_option_value((uint8_t *)"number", false, NULL, OPT_LOCAL);    set_option_value((uint8_t *)"relativenumber", false, NULL, OPT_LOCAL);    buf_set_term_title(curbuf, (char *)curbuf->b_ffname);    RESET_BINDING(curwin); +    // Apply TermOpen autocmds so the user can configure the terminal    apply_autocmds(EVENT_TERMOPEN, NULL, NULL, false, curbuf); @@ -958,7 +962,7 @@ static void refresh_terminal(Terminal *term)    buf_T *buf = handle_get_buffer(term->buf_handle);    bool valid = true;    if (!buf || !(valid = buf_valid(buf))) { -    // destroyed by `close_buffer`. Dont do anything else +    // Destroyed by `close_buffer`. Do not do anything else.      if (!valid) {        term->buf_handle = 0;      } @@ -1039,7 +1043,7 @@ static void refresh_scrollback(Terminal *term, buf_T *buf)    }  } -// Refresh the screen(visible part of the buffer when the terminal is +// Refresh the screen (visible part of the buffer when the terminal is  // focused) of a invalidated terminal  static void refresh_screen(Terminal *term, buf_T *buf)  { diff --git a/src/nvim/undo.c b/src/nvim/undo.c index 8cedfcb905..82ae0e8cf5 100644 --- a/src/nvim/undo.c +++ b/src/nvim/undo.c @@ -305,14 +305,9 @@ bool undo_allowed(void)    return true;  } -/* - * Get the undolevle value for the current buffer. - */ +/// Get the 'undolevels' value for the current buffer.  static long get_undolevel(void)  { -  if (curbuf->terminal) { -    return -1; -  }    if (curbuf->b_p_ul == NO_LOCAL_UNDOLEVEL)      return p_ul;    return curbuf->b_p_ul; | 
