Open jesseleite opened 2 years ago
This seems similar to #1185, but can't tell if it is exactly the same issue.
@l-kershaw Indeed looks that way, but I'm at a loss to what might be causing it.
I believe this may be related to the fact Telescope is causing the re-firing of the BufReadPost event when loaded. This is particularly evident when using lazy loading of telescope (e.g with packer) and trying to use the 'grep_files' Telescope command. The cursor position will always jump (due to this autocommand) and you grep the wrong word.
Running the command the second time works ok.
Not sure where in Telescope would be causing this event to fire.
It should be noted that the latest version of this 'jump last position' autocmd does not suffer from this problem
autocmd BufRead * autocmd FileType <buffer> ++once
\ if &ft !~# 'commit\|rebase' && line("'\"") > 1 && line("'\"") <= line("$") | exe 'normal! g`"' | endif
But there does still seem to be an issue with telescope.
Description
For those of us using Neovim's recommended autocmd for last position jump on
BufEnter
(see:help last-position-jump
), Neovim will restore last cursor position when re-opening a file.This works perfectly when opening a file using
:edit somefile
. However, if I opensomefile
using a Telescope fuzzy finder, it will open the file and move the cursor one character to the left.I never noticed this before, but it's messing with a custom autocmd I'm trying to write where I automatically highlight some text on BufEnter.
Neovim version
NVIM v0.5.1 Build type: Release LuaJIT 2.1.0-beta3 Compilation: clang -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1 -DNVIM_TS_HAS_SET_MATCH_LIMIT -O2 -DNDEBUG -Wall -Wextra -pedantic -Wno-unused-parameter -Wstrict-prototypes -std=gnu99 -Wshadow -Wconversion -Wmissing-prototypes -Wimplicit-fallthrough -Wvla -fstack-protector-strong -fno-common -fdiagnostics-color=auto -DINCLUDE_GENERATED_DECLARATIONS -D_GNU_SOURCE -DNVIM_MSGPACK_HAS_FLOAT32 -DNVIM_UNIBI_HAS_VAR_FROM -DMIN_LOG_LEVEL=3 -I/tmp/neovim-20210927-1441-demfsz/neovim-0.5.1/build/config -I/tmp/neovim-20210927-1441-demfsz/neovim-0.5.1/src -I/usr/local/include -I/Library/Developer/CommandLineTools/SDKs/MacOSX11.sdk/usr/include -I/usr/local/opt/gettext/include -I/tmp/neovim-20210927-1441-demfsz/neovim-0.5.1/build/src/nvim/auto -I/tmp/neovim-20210927-1441-demfsz/neovim-0.5.1/build/include Compiled by brew@BigSur
Features: +acl +iconv +tui See ":help feature-compile"
system vimrc file: "$VIM/sysinit.vim" fall-back for $VIM: "/usr/local/Cellar/neovim/0.5.1/share/nvim"
Run :checkhealth for more info
Operating system and version
macOS 11.2.1
checkhealth telescope
Steps to reproduce
:help last-position-jump
.:edit somefile
.:Telescope history
.Expected behavior
I would expect this last cursor position autocmd to behave exactly the same, whether you open a file using telescope, or by other means.
Actual behavior
Telescope finders are not restoring last cursor position correctly.
Minimal config