Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle possible errors from RangeVisibleInBuffer() #4192

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@
# - 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

Check warning on line 63 in python/ycm/scrolling_range.py

View check run for this annotation

Codecov / codecov/patch

python/ycm/scrolling_range.py#L62-L63

Added lines #L62 - L63 were not covered by tests

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 @@
start: Location = Location()
end: Location = Location()

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

Check warning on line 212 in python/ycm/vimsupport.py

View check run for this annotation

Codecov / codecov/patch

python/ycm/vimsupport.py#L209-L212

Added lines #L209 - L212 were not covered by tests

if not windows:
return None
Expand Down