diff options
author | Björn Linse <bjorn.linse@gmail.com> | 2019-07-15 18:23:11 +0200 |
---|---|---|
committer | Björn Linse <bjorn.linse@gmail.com> | 2019-08-06 17:01:47 +0200 |
commit | b0e26199ec02c9b392af6161522004c55db0441f (patch) | |
tree | c57e4cbd58018b8bf7e396239604b6e3e4943dfc /src/nvim/api/buffer.c | |
parent | 067a39ba854cc02a750911ead968a744b2769aac (diff) | |
download | rneovim-b0e26199ec02c9b392af6161522004c55db0441f.tar.gz rneovim-b0e26199ec02c9b392af6161522004c55db0441f.tar.bz2 rneovim-b0e26199ec02c9b392af6161522004c55db0441f.zip |
lua: add {old_byte_size} to on_lines buffer change event
Diffstat (limited to 'src/nvim/api/buffer.c')
-rw-r--r-- | src/nvim/api/buffer.c | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/src/nvim/api/buffer.c b/src/nvim/api/buffer.c index b0b65545ab..497b4ae9a4 100644 --- a/src/nvim/api/buffer.c +++ b/src/nvim/api/buffer.c @@ -1176,6 +1176,29 @@ free_exit: return 0; } +Dictionary nvim__buf_stats(Buffer buffer, Error *err) +{ + Dictionary rv = ARRAY_DICT_INIT; + + buf_T *buf = find_buffer_by_handle(buffer, err); + if (!buf) { + return rv; + } + + // Number of times the cached line was flushed. + // This should generally not increase while editing the same + // line in the same mode. + PUT(rv, "flush_count", INTEGER_OBJ(buf->flush_count)); + // lnum of current line + PUT(rv, "current_lnum", INTEGER_OBJ(buf->b_ml.ml_line_lnum)); + // whether the line has unflushed changes. + PUT(rv, "line_dirty", BOOLEAN_OBJ(buf->b_ml.ml_flags & ML_LINE_DIRTY)); + // NB: this should be zero at any time API functions are called, + // this exists to debug issues + PUT(rv, "dirty_bytes", INTEGER_OBJ((Integer)buf->deleted_bytes)); + return rv; +} + // Check if deleting lines made the cursor position invalid. // Changed lines from `lo` to `hi`; added `extra` lines (negative if deleted). static void fix_cursor(linenr_T lo, linenr_T hi, linenr_T extra) |