Skip to content

Commit 88ed5a7

Browse files
authored
Merge pull request #4192 from bstaletic/errors-from-range-visible-in-buffer
Handle possible errors from RangeVisibleInBuffer()
2 parents bf0dbea + 4b3df69 commit 88ed5a7

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

python/ycm/scrolling_range.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,13 @@ def Request( self, force=False ):
5555
# - look up the actual visible range, then call this function
5656
# - if not overlapping, do the factor expansion and request
5757
self._last_requested_range = vimsupport.RangeVisibleInBuffer( self._bufnr )
58+
# If this is false, either the self._bufnr is not a valid buffer number or
59+
# the buffer is not visible in any window.
60+
# Since this is called asynchronously, a user may bwipeout a buffer with
61+
# self._bufnr number between polls.
62+
if self._last_requested_range is None:
63+
return False
64+
5865
self._tick = vimsupport.GetBufferChangedTick( self._bufnr )
5966

6067
# We'll never use the last response again, so clear it

python/ycm/vimsupport.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,10 @@ class Range:
206206
start: Location = Location()
207207
end: Location = Location()
208208

209-
buffer = vim.buffers[ bufnr ]
209+
try:
210+
buffer = vim.buffers[ bufnr ]
211+
except KeyError:
212+
return None
210213

211214
if not windows:
212215
return None

0 commit comments

Comments
 (0)