[vim/vim] Text property is not removed on some lines of multiline text property region (#8261)

25 views
Skip to first unread message

reportaman

unread,
May 25, 2021, 9:22:00 PM5/25/21
to vim/vim, Subscribed

Describe the bug
Text property is not removed from all lines in range as promised by function prop_remove().

To Reproduce
Please follow exact steps with exact same files, most changes to temp.vim below makes the issue non-reproducible.

  1. Save temp.vim, and steps.vim in same directory on your machine.
  2. Run command >>vim --clean -u steps.vim or just vim -u steps.vim.
  3. Thats it! As can be seen text property ("someprop") did not clear on line 40 when call prop_remove({'type':'someprop', 'bufnr':bufnr()},35,43) is executed to remove it from all lines in range [35:43].

command: >>vim --clean -u steps.vim or just vim -u steps.vim

file steps.vim:

set nocompatible

filetype plugin on

set noswapfile

set updatetime=50

set updatecount=0

set number

syntax enable

silent edit temp.vim

highlight SomeHighlight ctermfg=233 ctermbg=118 guifg=#121212 guibg=#87FF00

call prop_type_add('someprop', {'highlight': 'SomeHighlight', 'combine': 0})

call prop_add(1, 27, {'end_lnum': 1, 'end_col': 70, 'type': 'someprop', 'bufnr': bufnr()})

call prop_remove({'type':'someprop', 'bufnr':bufnr()},1,1)

call prop_add(35, 22, {'end_lnum': 43, 'end_col': 43, 'type': 'someprop', 'bufnr': bufnr()})

call prop_remove({'type':'someprop', 'bufnr':bufnr()},35,43)

file temp.vim (don't change anything, save it exactly as it is, don't even add extra line on top in file or additional space; reproducibility is sensitive to not changing contents of this file. First line in the file should go on first line in temp.vim in the following code snippet):

" vim-plug plugin manager (from https://github.com/junegunn/vim-plug)



"       Specify a directory for plugins

"               - For Neovim: stdpath('data') . '/plugged'

"               - Avoid using standard Vim directory names like 'plugin'



set nocompatible " no need to be compatible with old vim

filetype plugin on

set noswapfile

set updatetime=50 " TODO: This is again set to 0 after loading plugins. ale/devicons comibanation gave some trouble in past, check again if a bigger value is needed

set updatecount=0

" Colorscheme specific setup

let g:ale_disable_lsp = 1

let g:airline_extensions = []

let g:airline#extensions#disable_rtp_load = 1

"let g:startify_disable_at_vimenter = 1

"let g:airline_disable_statusline = 1

"let g:loaded_ctrlp = 1

if !empty($VIM_TAB_COLOR) && !(str2nr($VIM_TAB_COLOR,10) == 0)

    let tabcolor=$VIM_TAB_COLOR

else

    let tabcolor=244

endif



function! DoNothing()

    let g:airline_disable_statusline = 0

    set laststatus=0

    set laststatus=2

    "let g:loaded_ctrlp = 0

    execute 'Startify'

    execute 'colorscheme PaperColor'

    "let g:vim_monokai_tasty_italic = 1

    "colorscheme vim-monokai-tasty

    "let g:airline_theme='monokai_tasty'

    let &t_8f="\<Esc>[38;2;%lu;%lu;%lum"

    let &t_8b="\<Esc>[48;2;%lu;%lu;%lum"

    hi Function cterm=italic gui=italic term=italic

    hi Normal ctermbg=NONE guibg=NONE

    let g:afterglow_use_italics=1

    let g:afterglow_italic_comments=1

    hi! Comment cterm=italic gui=italic term=italic

    "call plug#load(keys(g:plugs))

    "call plug#load(['ctrlpvim/ctrlp.vim'])  | Helptags

"    hi Error ctermbg=NONE guibg=NONE

"    hi! Normal ctermbg=NONE guibg=NONE

"    hi! NonText ctermbg=NONE guibg=NONE

"    hi ErrorMsg ctermbg=NONE ctermfg=red guibg=NONE guifg=0xFF0000

"    hi WarningMsg ctermbg=NONE ctermfg=magenta guibg=NONE guifg=#FF0088

"    hi VertSplit ctermfg=241 ctermbg=NONE cterm=NONE guibg=NONE guifg=#777777

"    " indentLine customization

"    let g:indentLine_char_list = ['│']

"    let g:indentLine_concealcursor = 'inc'

"    let g:indentLine_conceallevel = 2

"    let g:indentLine_defaultGroup = 'SpecialKey'

"    let g:indentLine_setColors = 1

"    

"    let g:indentLine_bgcolor_term = 'NONE'

"    let g:indentLine_bgcolor_gui = 'NONE'

"    let g:indentLine_color_term = 240

"    let g:indentLine_color_gui = '#555555'

"    "    if !empty($VIM_TAB_COLOR) && !(str2nr($VIM_TAB_COLOR,10) == 0)

"    "        let tabcolor=$VIM_TAB_COLOR

"    "    else

"    "        let tabcolor=244

"    "    endif

endfunction

"function! StartifyEntryFormat()

"        return 'WebDevIconsGetFileTypeSymbol(absolute_path) ." ". entry_path'

"endfunction



"call plug#begin('~/.vim/plugged')



" Make sure you use single quotes

" Shorthand notation; fetches https://github.com/junegunn/vim-easy-align

" Any valid git URL is allowed

"if has('nvim')

"    Plug 'caenrique/nvim-toggle-terminal'

"    nnoremap <silent> <leader>= :ToggleWindowTerminal<Enter>

"    tnoremap <silent> <leader>= <C-\><C-n>:ToggleWindowTerminal<Enter>

"    function! s:termCww()

"        let w:termcww=1

"        exec 'wincmd w'

"    endfunction

"    tnoremap <silent> <C-w><C-w> <C-\><C-n> :call <SID>termCww()<CR>

"    tnoremap <silent> <C-w>w <C-\><C-n> :call <SID>termCww()<CR>

"    function! s:termWinEnter()

"        if  &filetype==#'terminal' && mode()==#'n' && w:termcww==1

"            let w:termcww=0

"            call feedkeys('i','nt')

"        endif

"    endfunction

"    augroup TermCww

"        autocmd!

"        autocmd WinEnter * call <SID>termWinEnter()

"    augroup END

"end



"call plug#end()

Expected behavior
prop_remove() should remove specified property on all lines in line range provided by the user.

Screenshots
Look at the uncleared green background on line 40:
Screen Shot 2021-05-25 at 6 10 44 PM

Environment (please complete the following information):

  • Vim version
VIM - Vi IMproved 8.2 (2019 Dec 12, compiled May 24 2021 17:37:26)

macOS version - arm64

Included patches: 1-2884

Compiled by Homebrew

  • OS: macOS 11.3 (ARM64, i.e. M1 mac)
  • Terminal: Doesn't matter, happens on all terminals I have installed: Terminal.App, iTerm2, Alacritty, WezTerm.


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub, or unsubscribe.

lacygoill

unread,
May 26, 2021, 8:44:59 AM5/26/21
to vim/vim, Subscribed

There are still a few magic numbers, but here is a simplified MWE:

vim -Nu NONE -S <(cat <<'EOF'
    vim9script
    var lines: list<string> = [repeat('x', 35)]->repeat(41)
                            + [repeat('!', 35)]
                            + [repeat('x', 35)]->repeat(56)
    lines->setline(1)
    prop_type_add('someprop', {highlight: 'ErrorMsg'})
    prop_add(1, 27, {end_lnum: 1, end_col: 70, type: 'someprop'})
    prop_remove({type: 'someprop'}, 1)
    prop_add(35, 22, {end_lnum: 43, end_col: 43, type: 'someprop'})
    prop_remove({type: 'someprop'}, 35, 43)
    norm! 42G
EOF
)

Bram Moolenaar

unread,
May 26, 2021, 4:32:51 PM5/26/21
to vim/vim, Subscribed

Closed #8261 via 840f91f.

reportaman

unread,
May 26, 2021, 5:27:29 PM5/26/21
to vim/vim, Subscribed

@brammool Thanks. Btw, there are other problems with text properties. With @lacygoill 's example above if you remove last prop_remove, and insert some text within the region it doesn't always apply the text property to the text added within the region in cases:

  1. new text is inserted right after a newline
  2. new text is inserted anywhere on a new blank line in region

Moreover for more complex edits in my real world experience, I get internal errors associated with text properties if I edit the buffer.

Here's a video:

https://user-images.githubusercontent.com/71736629/119733311-31e81b00-be2e-11eb-8047-ceabe3924d4d.mp4

Command:

 vim -Nu NONE -S <(cat <<'EOF'
    vim9script
    var lines: list<string> = [repeat('x', 35)]->repeat(41)
                            + [repeat('!', 35)]
                            + [repeat('x', 35)]->repeat(56)
    lines->setline(1)
    prop_type_add('someprop', {highlight: 'ErrorMsg'})
    prop_add(1, 27, {end_lnum: 1, end_col: 70, type: 'someprop'})
    prop_remove({type: 'someprop'}, 1
)
    prop_add(35, 22, {end_lnum: 43, end_col: 43, type: 'someprop'})
    norm! 42G
EOF
)

Bram Moolenaar

unread,
May 27, 2021, 7:18:50 AM5/27/21
to vim/vim, Subscribed

Reopened #8261.

paul-ollis

unread,
May 17, 2022, 5:47:57 AM5/17/22
to vim/vim, Subscribed

I can reproduce the effect in the video this using a 27 May 2021 build, but not with the latest code. So I think this can be closed.


Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issues/8261/1128657684@github.com>

Bram Moolenaar

unread,
May 17, 2022, 7:07:40 AM5/17/22
to vim/vim, Subscribed

Closed #8261.


Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issue/8261/issue_event/6623499890@github.com>

lacygoill

unread,
May 24, 2022, 2:38:32 AM5/24/22
to vim/vim, Subscribed

This todo item is no longer relevant:

  • In some cases prop_remove() does not work correctly. (#8261)


Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issues/8261/1135469360@github.com>

Bram Moolenaar

unread,
May 24, 2022, 8:59:05 AM5/24/22
to vim/vim, Subscribed


> [This todo item](https://github.com/vim/vim/blob/c9a431c7638ecebb6f2cb3eabd0e1b2b5e269c1e/runtime/doc/todo.txt#L94) is no longer relevant:
>
> - In some cases prop_remove() does not work correctly. (#8261)

I'll delete it.

--
Microsoft's definition of a boolean: TRUE, FALSE, MAYBE
"Embrace and extend"...?

/// Bram Moolenaar -- ***@***.*** -- http://www.Moolenaar.net \\\
/// \\\
\\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///


Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issues/8261/1135890758@github.com>

Reply all
Reply to author
Forward
0 new messages