Skip to content

Commit

Permalink
Merge pull request #4192 from bstaletic/errors-from-range-visible-in-…
Browse files Browse the repository at this point in the history
…buffer

Handle possible errors from RangeVisibleInBuffer()
  • Loading branch information
mergify[bot] authored Oct 4, 2023
2 parents bf0dbea + 4b3df69 commit 88ed5a7
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
7 changes: 7 additions & 0 deletions python/ycm/scrolling_range.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,13 @@ def Request( self, force=False ):
# - look up the actual visible range, then call this function
# - if not overlapping, do the factor expansion and request
self._last_requested_range = vimsupport.RangeVisibleInBuffer( self._bufnr )
# If this is false, either the self._bufnr is not a valid buffer number or
# the buffer is not visible in any window.
# Since this is called asynchronously, a user may bwipeout a buffer with
# self._bufnr number between polls.
if self._last_requested_range is None:
return False

self._tick = vimsupport.GetBufferChangedTick( self._bufnr )

# We'll never use the last response again, so clear it
Expand Down
5 changes: 4 additions & 1 deletion python/ycm/vimsupport.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,10 @@ class Range:
start: Location = Location()
end: Location = Location()

buffer = vim.buffers[ bufnr ]
try:
buffer = vim.buffers[ bufnr ]
except KeyError:
return None

if not windows:
return None
Expand Down

0 comments on commit 88ed5a7

Please sign in to comment.