diff options
| author | fdschmidt93 <39233597+fdschmidt93@users.noreply.github.com> | 2021-09-10 13:21:04 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-09-10 13:21:04 +0200 |
| commit | 1c35ea319e847e07653cde5bb817daba8dd83a70 (patch) | |
| tree | 91f4baa096c89d970d97653d4199ba1802250093 /lua/telescope/make_entry.lua | |
| parent | b4d6eb9a232dab48ce658470a980e7a15edb500f (diff) | |
fix: stale lnum in buffer previewer (#1229)
* fix: lnum to jump to might be stale eg when resuming buffer picker after changes
Diffstat (limited to 'lua/telescope/make_entry.lua')
| -rw-r--r-- | lua/telescope/make_entry.lua | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/lua/telescope/make_entry.lua b/lua/telescope/make_entry.lua index f6fed2d..beb7e18 100644 --- a/lua/telescope/make_entry.lua +++ b/lua/telescope/make_entry.lua @@ -452,6 +452,7 @@ function make_entry.gen_from_buffer(opts) local readonly = vim.api.nvim_buf_get_option(entry.bufnr, "readonly") and "=" or " " local changed = entry.info.changed == 1 and "+" or " " local indicator = entry.flag .. hidden .. readonly .. changed + local line_count = vim.api.nvim_buf_line_count(entry.bufnr) return { valid = true, @@ -462,8 +463,8 @@ function make_entry.gen_from_buffer(opts) bufnr = entry.bufnr, filename = bufname, - - lnum = entry.info.lnum ~= 0 and entry.info.lnum or 1, + -- account for potentially stale lnum as getbufinfo might not be updated or from resuming buffers picker + lnum = entry.info.lnum ~= 0 and math.max(math.min(entry.info.lnum, line_count), 1) or 1, indicator = indicator, } end |
