Giter VIP home page Giter VIP logo

Comments (4)

cridemichel avatar cridemichel commented on June 15, 2024

FOLLOW UP

Considering the error messages and the fact that "hidden" option is false, it seems that coc is trying to add highlights to a non existing buffer, indeed if the function "s:add_highlights_timer" in "autoload/coc/highlight.vim", i.e.

function! s:add_highlights_timer(bufnr, ns, highlights, priority) abort
  let hls = []
  let next = []
  for i in range(0, len(a:highlights) - 1)
    if i < g:coc_highlight_maximum_count
      call add(hls, a:highlights[i])
    else
      call add(next, a:highlights[i])
    endif
  endfor
  call s:add_highlights(a:bufnr, a:ns, hls, a:priority)
  if len(next)
    call timer_start(30, {->s:add_highlights_timer(a:bufnr, a:ns, next, a:priority)})
  endif
endfunction

is changed as follows:

function! s:add_highlights_timer(bufnr, ns, highlights, priority) abort
  let hls = []
  let next = []
  for i in range(0, len(a:highlights) - 1)
    if i < g:coc_highlight_maximum_count
      call add(hls, a:highlights[i])
    else
      call add(next, a:highlights[i])
    endif
  endfor
  if bufwinnr(a:bufnr)!=-1   " check if buffer still exists     
    call s:add_highlights(a:bufnr, a:ns, hls, a:priority)
  endif
  if len(next) && bufwinnr(a:bufnr) != -1 "check if buffer still exists
    call timer_start(30, {->s:add_highlights_timer(a:bufnr, a:ns, next, a:priority)})
  endif
endfunction

error messages disappear. Note that adding highlights is prevented if buffer does not exist.
I do not know whether this is an appropriate fix or not, but I hope this helps fixing this issue,

best Cristiano

from coc.nvim.

fannheyward avatar fannheyward commented on June 15, 2024

Thank you for your report. Reproduced in vim with set nohidden, and made a PR with fix.

from coc.nvim.

cridemichel avatar cridemichel commented on June 15, 2024

Hi,
there are still problems, if you open the file "molgl.c" with vim
(using the minimal vimrc file which I uploaded) and just after having open it:

  1. press arrow down key

  2. press <shift-o> to enter a new line and to switch to "insert mode"

  3. press <Esc>

you will get again error messages,

unfortunately, I do not any fix to suggest yet,
best C.

from coc.nvim.

cridemichel avatar cridemichel commented on June 15, 2024

FOLLOW UP:

the only fix which I found is to ignore error E964 by modifying the function "s:funcs.buf_add_highlight" in
autoload/coc/api.vim as follows:

function! s:funcs.buf_add_highlight(bufnr, srcId, hlGroup, line, colStart, colEnd, ...) abort
  if a:srcId == 0
    let srcId = s:max_src_id + 1
    let s:max_src_id = srcId
  else
    let srcId = a:srcId
  endif
  let bufnr = a:bufnr == 0 ? bufnr('%') : a:bufnr
  let type = srcId == -1 ? a:hlGroup : a:hlGroup.'_'.srcId
  let types = get(s:id_types, srcId, [])
  if index(types, type) == -1
    call add(types, type)
    let s:id_types[srcId] = types
    if empty(prop_type_get(type))
      call prop_type_add(type, extend({'highlight': a:hlGroup}, get(a:, 1, {})))
    endif
  endif
  let end = a:colEnd == -1 ? strlen(get(getbufline(bufnr, a:line + 1), 0, '')) + 1 : a:colEnd + 1
  if end < a:colStart + 1
    return
  endif
  let id = s:generate_id(a:bufnr)
  try
    call prop_add(a:line + 1, a:colStart + 1, {'bufnr': bufnr, 'type': type, 'id': id, 'end_col': end})
  catch /^Vim\%((\a\+)\)\=:\(E967\|E964\)/ 
    " ignore 967 and 964
  endtry
  if a:srcId == 0
    " return generated srcId
    return srcId
  endif
  return v:null
endfunction

where in the regexp of catch statement I replaced

 /^Vim\%((\a\+)\)\=:E967/

with

 /^Vim\%((\a\+)\)\=:\(E967\|E964\)/

best C.

from coc.nvim.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.