Open ShawnROGrady opened 6 months ago
A second problem which probably has the same root cause: ALEFix clears the entire jump list when it changes anything. So ^O
won't work any more, for example. This happens even if the buffer is only opened in one view.
Test:
:jumps
:ALEFix
:jumps
Did some research on this. Basically, it's expected behavior of nvim_buf_set_lines
. However, I think that settings the lines individually won't have this problem (source).
if l:has_bufline_api
if has('nvim')
" save and restore signs to avoid flickering
let signs = sign_getplaced(a:buffer, {'group': 'ale'})[0].signs
for i in range(len(l:new_lines))
call nvim_buf_set_lines(a:buffer, i, i + 1, 0, [l:new_lines[i]])
endfor
" restore signs (invalid line numbers will be skipped)
call sign_placelist(map(signs, {_, v -> extend(v, {'buffer': a:buffer})}))
else
call setbufline(a:buffer, 1, l:new_lines)
endif
call deletebufline(a:buffer, l:first_line_to_remove, '$')
" Fall back on setting lines the old way, for the current buffer.
else
A real solution for this probably involves actually diffing the new and original files, and only modifying those lines which actually changed. I also don't really understand why the nvim case uses this newer API in the first place (seems like saving/restoring the signs could be done with the old API as well).
Information
VIM version
Also reproduced on
Operating System:
macOS Sonoma versions 14.2 + 14.3.1
What went wrong
In neovim, if I have a split buffer and run
:ALEFix
(either directly or on save withg:ale_fix_on_save=1
) then the cursor will jump to the top of the non-focused buffer. This can be very annoying since frequently when working on larger files I make use of split buffers so I can reference one part of the file while working on another part of that same file.The same issue is not present when using vim.
~I believe this was caused by https://github.com/dense-analysis/ale/pull/3974, since everything worked as expected when I removed these changes locally (I just updated
autoload/ale/util.vim
to callsetbufline(a:buffer, 1, l:new_lines)
for both vim and nvim).~ EDIT: I think I misspoke here. I am still seeing the same issue in certain cases even after removing the changes I mentioned above. Specifically I was seeing this issue on both of my main machines, and while removing the above changes appears to have resolved the problems on one of them I am still seeing problems on the other.Reproducing the bug
:ALEFix
Below is a screen recording of this unexpected behaviour in neovim for a python file where I have
black
as a fixer, but I have had the same issue with other filetypes+fixers (specifically was having issues withocaml
+ocamlformat
as well)::ALEInfo
Expand
Current Filetype: python Available Linters: ['bandit', 'cspell', 'flake8', 'flakehell', 'jedils', 'mypy', 'prospector', 'pycln', 'pycodestyle', 'pydocstyle', 'pyflakes', 'pylama', 'pylint', 'pylsp', 'pyre', 'pyright', 'refurb', 'ruff', 'unimport', 'vulture'] Linter Aliases: 'jedils' -> ['jedi_language_server'] Enabled Linters: ['flake8', 'mypy', 'pylint', 'pyright', 'ruff'] Ignored Linters: ['pyright'] Suggested Fixers: 'add_blank_lines_for_python_control_statements' - Add blank lines before control statements. 'autoflake' - Fix flake issues with autoflake. 'autoimport' - Fix import issues with autoimport. 'autopep8' - Fix PEP8 issues with autopep8. 'black' - Fix PEP8 issues with black. 'isort' - Sort Python imports with isort. 'pycln' - remove unused python import statements 'pyflyby' - Tidy Python imports with pyflyby. 'remove_trailing_lines' - Remove all blank lines at the end of a file. 'reorder-python-imports' - Sort Python imports with reorder-python-imports. 'ruff' - A python linter/fixer for Python written in Rust 'ruff_format' - Fix python files with the ruff formatter. 'trim_whitespace' - Remove all trailing whitespace characters at the end of every line. 'yapf' - Fix Python files with yapf. Linter Variables: let g:ale_python_auto_pipenv = 0 let g:ale_python_auto_poetry = 0 let g:ale_python_auto_virtualenv = 0 let g:ale_python_black_auto_pipenv = 0 let g:ale_python_black_auto_poetry = 0 let g:ale_python_black_change_directory = 1 let g:ale_python_black_executable = 'black' let g:ale_python_black_options = '' let g:ale_python_black_use_global = 0 let g:ale_python_flake8_auto_pipenv = 0 let g:ale_python_flake8_auto_poetry = 0 let g:ale_python_flake8_change_directory = 'project' let g:ale_python_flake8_executable = 'flake8' let g:ale_python_flake8_options = '--max-line-length=90' let g:ale_python_flake8_use_global = 0 let g:ale_python_isort_auto_pipenv = 0 let g:ale_python_isort_auto_poetry = 0 let g:ale_python_isort_executable = 'isort' let g:ale_python_isort_options = '' let g:ale_python_isort_use_global = 0 let g:ale_python_mypy_auto_pipenv = 0 let g:ale_python_mypy_auto_poetry = 0 let g:ale_python_mypy_executable = 'mypy' let g:ale_python_mypy_ignore_invalid_syntax = 0 let g:ale_python_mypy_options = '--ignore-missing-imports' let g:ale_python_mypy_show_notes = 1 let g:ale_python_mypy_use_global = 0 let g:ale_python_pylint_auto_pipenv = 0 let g:ale_python_pylint_auto_poetry = 0 let g:ale_python_pylint_change_directory = 1 let g:ale_python_pylint_executable = 'python3' let g:ale_python_pylint_options = '' let g:ale_python_pylint_use_global = 0 let g:ale_python_pylint_use_msg_id = 0 let g:ale_python_pyright_auto_pipenv = 0 let g:ale_python_pyright_auto_poetry = 0 let g:ale_python_pyright_config = {} let g:ale_python_pyright_executable = 'pyright-langserver' let g:ale_python_pyright_use_global = 0 let g:ale_python_ruff_auto_pipenv = 0 let g:ale_python_ruff_auto_poetry = 0 let g:ale_python_ruff_change_directory = 1 let g:ale_python_ruff_executable = 'ruff' let g:ale_python_ruff_options = '' let g:ale_python_ruff_use_global = 0 Global Variables: let g:ale_cache_executable_check_failures = v:null let g:ale_change_sign_column_color = v:null let g:ale_command_wrapper = '' let g:ale_completion_delay = v:null let g:ale_completion_enabled = 0 let g:ale_completion_max_suggestions = v:null let g:ale_disable_lsp = 1 let g:ale_echo_cursor = 1 let g:ale_echo_msg_error_str = 'Error' let g:ale_echo_msg_format = '%code: %%s' let g:ale_echo_msg_info_str = 'Info' let g:ale_echo_msg_warning_str = 'Warning' let g:ale_enabled = 1 let g:ale_fix_on_save = 0 let g:ale_fixers = {'cpp': ['clang-format'], 'lisp': ['scmindent'], 'typescript': ['prettier'], 'dune': ['scmindent'], 'go': [], 'haskell': ['hindent'], 'ocaml': ['ocamlformat'], 'python': ['isort', 'black'], 'racket': ['scmindent'], 'c': ['clang-format'], 'proto': ['clang-format'], 'typescriptreact': ['prettier'], 'rust': ['rustfmt'], 'javascript': ['eslint', 'prettier'], 'swift': ['swiftformat'], 'arduino': ['clang-format']} let g:ale_history_enabled = 1 let g:ale_info_default_mode = 'preview' let g:ale_history_log_output = 1 let g:ale_keep_list_window_open = 0 let g:ale_lint_delay = 200 let g:ale_lint_on_enter = 1 let g:ale_lint_on_filetype_changed = 1 let g:ale_lint_on_insert_leave = 0 let g:ale_lint_on_save = 1 let g:ale_lint_on_text_changed = 'never' let g:ale_linter_aliases = {} let g:ale_linters = {'swift': ['swiftlint', 'sourcekitlsp'], 'go': ['golangci-lint', 'staticcheck'], 'haskell': ['stack_build', 'stack_ghc'], 'rust': ['cargo'], 'javascript': ['eslint'], 'ocaml': ['merlin']} let g:ale_linters_explicit = 0 let g:ale_linters_ignore = {} let g:ale_list_vertical = 0 let g:ale_list_window_size = 10 let g:ale_loclist_msg_format = '%code: %%s' let g:ale_max_buffer_history_size = 20 let g:ale_max_signs = v:null let g:ale_maximum_file_size = v:null let g:ale_open_list = 0 let g:ale_pattern_options = v:null let g:ale_pattern_options_enabled = v:null let g:ale_root = {} let g:ale_set_balloons = 0 let g:ale_set_highlights = 0 let g:ale_set_loclist = 1 let g:ale_set_quickfix = 0 let g:ale_set_signs = 1 let g:ale_sign_column_always = v:null let g:ale_sign_error = '>>' let g:ale_sign_info = '--' let g:ale_sign_offset = v:null let g:ale_sign_style_error = v:null let g:ale_sign_style_warning = v:null let g:ale_sign_warning = v:null let g:ale_sign_highlight_linenrs = v:null let g:ale_type_map = {} let g:ale_use_neovim_diagnostics_api = 1 let g:ale_use_global_executables = v:null let g:ale_virtualtext_cursor = 'disabled' let g:ale_warn_about_trailing_blank_lines = 1 let g:ale_warn_about_trailing_whitespace = 1 Command History: (finished - exit code 0) ['/bin/zsh', '-c', '''python3'' --version'] <<