dense-analysis / dense-analysis/ale

The option `previewpopup` causes errors when set

Open
#3,213 5 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
Vim Script
Stars
14k
Forks
1.5k
Avg merge
17h 49m
Merged PRs (30d)
1

Description

## Information

**VIM version**

VIM - Vi IMproved 8.2 (2019 Dec 12, compiled Jun 16 2020 22:38:24)
Included patches: 1-992

**Operating System**

Ubuntu 20.04

## What went wrong

When the `'previewpopup'` option is non-empty, an ALE command which makes the popup window the "current" window (such as with `:wincmd P`) will throw `E441: There is no preview window`. This can be seen with `:ALEDetail`.

Relevant `:help` for `'previewpopup'`:

`When not empty a popup window is used for commands that would open a preview window.`

## Reproducing the bug

1. Open vim to a file linted by ALE.
2. Do `:set previewpopup=height:10,width:60`
3. Create an error in the file so that ALE indicates the error.
4. Place the cursor on the same line as the error.
5. Do `:ALEDetail`
6. See the message:

```
Error detected while processing function ale#cursor#ShowCursorDetail[17]..112_S
howCursorDetailForItem[6]..ale#preview#Show:
line 4:
E441: There is no preview window
```

The relevant function is this one:
``` vimscript
function! ale#preview#Show(lines, ...) abort
let l:options = get(a:000, 0, {})

silent pedit ALEPreviewWindow
wincmd P

setlocal modifiable
setlocal noreadonly
[it goes on but that's the relevant part]
endfunction
```

It can be seen that the `wincmd P` on line 4 is causing the error, as popup windows cannot be entered directly for editing. Either this case should be checked for in advance, or this function should use a different method to modify the preview window, such as `win_execute()`, `setwinvar()`, `setbufvar()`, or `popup_settext()`.

### :ALEInfo

```
Current Filetype: vim
Available Linters: ['ale_custom_linting_rules', 'vimls', 'vint']
Enabled Linters: ['ale_custom_linting_rules', 'vimls', 'vint']
Suggested Fixers:
'remove_trailing_lines' - Remove all blank lines at the end of a file.
'trim_whitespace' - Remove all trailing whitespace characters at the end of every line.
Linter Variables:

let g:ale_vim_vimls_config = {}
let g:ale_vim_vimls_executable = 'vim-language-server'
let g:ale_vim_vimls_use_global = 0
let g:ale_vim_vint_executable = 'vint'
let g:ale_vim_vint_show_style_issues = 1
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_echo_cursor = 1
let g:ale_echo_msg_error_str = 'Error'
let g:ale_echo_msg_format = '[%severity%] %code: %%s [%linter%]'
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 = 1
let g:ale_fixers = {'dart': ['dartfmt'], 'python': ['autopep8']}
let g:ale_history_enabled = 1
let g:ale_history_log_output = 1
let g:ale_keep_list_window_open = 1
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 = 1
let g:ale_lint_on_save = 1
let g:ale_lint_on_text_changed = 'normal'
let g:ale_linter_aliases = {}
let g:ale_linters = {'sh': ['language_server', 'shell', 'shellcheck'], 'dart': ['language_server'], 'python': ['bandit', 'flake8', 'mypy']}
let g:ale_linters_explicit = 0
let g:ale_list_vertical = 0
let g:ale_list_window_size = 5
let g:ale_loclist_msg_format = '[%severity%] %code: %%s [%linter%]'
let g:ale_lsp_root = {}
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_set_balloons = 0
let g:ale_set_highlights = 1
let g:ale_set_loclist = 1
let g:ale_set_quickfix = 0
let g:ale_set_signs = 0
let g:ale_sign_column_always = v:null
let g:ale_sign_error = v:null
let g:ale_sign_info = v:null
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_statusline_format = v:null
let g:ale_type_map = {}
let g:ale_use_global_executables = v:null
let g:ale_virtualtext_cursor = 0
let g:ale_warn_about_trailing_blank_lines = 1
let g:ale_warn_about_trailing_whitespace = 1
Command History:

(executable check - failure) vim-language-server
(executable check - success) vint
(finished - exit code 0) ['/bin/bash', '-c', '''vint'' --version']

<<>>
0.4a4.dev8+g5b05880
<<>>

(finished - exit code 1) ['/bin/bash', '-c', '''vint'' -s --no-color -f "{file_path}:{line_number}:{column_number}: {severity}: {description} (see {reference})" ''/tmp/v7WAIZa/2/vimrc''']

<<>>
/tmp/v7WAIZa/2/vimrc:402:29: error: unexpected token: (see vim-jp/vim-vimlparser)
Total violations: 1
<<>>

(executable check - failure) vim-language-server
(finished - exit code 1) ['/bin/bash', '-c', '''vint'' -s --no-color -f "{file_path}:{line_number}:{column_number}: {severity}: {description} (see {reference})" ''/tmp/v7WAIZa/3/vimrc''']

<<>>
/tmp/v7WAIZa/3/vimrc:264:5: error: E492: Not an editor command: ddd (see vim-jp/vim-vimlparser)
Total violations: 1
<<>>
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.