diff options
author | Björn Linse <bjorn.linse@gmail.com> | 2020-09-09 16:50:53 +0200 |
---|---|---|
committer | Björn Linse <bjorn.linse@gmail.com> | 2020-09-10 06:50:04 +0200 |
commit | ef5e7b862db38d3b0376417e137c6463c4d909e6 (patch) | |
tree | bd4ed64c3ca45f8f378056c2eeeeacff7f936208 | |
parent | f239134feee39d6a785726a0bfcd53940609a35f (diff) | |
download | rneovim-ef5e7b862db38d3b0376417e137c6463c4d909e6.tar.gz rneovim-ef5e7b862db38d3b0376417e137c6463c4d909e6.tar.bz2 rneovim-ef5e7b862db38d3b0376417e137c6463c4d909e6.zip |
memline: do not attempt to cache line2byte()
This is irrelevant to neovim usecases anyway.
-rw-r--r-- | src/nvim/memline.c | 9 | ||||
-rw-r--r-- | src/nvim/memline_defs.h | 1 |
2 files changed, 8 insertions, 2 deletions
diff --git a/src/nvim/memline.c b/src/nvim/memline.c index ebd86a3f7d..f9390bcb88 100644 --- a/src/nvim/memline.c +++ b/src/nvim/memline.c @@ -4012,8 +4012,13 @@ long ml_find_line_or_offset(buf_T *buf, linenr_T lnum, long *offp, bool no_ff) // This is used by the extmark code which needs the byte offset of the edited // line. So when doing multiple small edits on the same line the value is // only calculated once. + // + // NB: caching doesn't work with 'fileformat'. This is not a problem for + // bytetracking, as bytetracking ignores 'fileformat' option. But calling + // line2byte() will invalidate the cache for the time being (this function + // was never cached to start with anyway). bool can_cache = (lnum != 0 && !ffdos && buf->b_ml.ml_line_lnum == lnum); - if (lnum == 0 || buf->b_ml.ml_line_lnum < lnum) { + if (lnum == 0 || buf->b_ml.ml_line_lnum < lnum || !no_ff) { ml_flush_line(curbuf); } else if (can_cache && buf->b_ml.ml_line_offset > 0) { return buf->b_ml.ml_line_offset; @@ -4113,7 +4118,7 @@ long ml_find_line_or_offset(buf_T *buf, linenr_T lnum, long *offp, bool no_ff) } } - if (can_cache) { + if (can_cache && size > 0) { buf->b_ml.ml_line_offset = size; } diff --git a/src/nvim/memline_defs.h b/src/nvim/memline_defs.h index 3994632807..9a6f29a908 100644 --- a/src/nvim/memline_defs.h +++ b/src/nvim/memline_defs.h @@ -58,6 +58,7 @@ typedef struct memline { linenr_T ml_line_lnum; // line number of cached line, 0 if not valid char_u *ml_line_ptr; // pointer to cached line size_t ml_line_offset; // cached byte offset of ml_line_lnum + int ml_line_offset_ff; // fileformat of cached line bhdr_T *ml_locked; // block used by last ml_get linenr_T ml_locked_low; // first line in ml_locked |