Skip to content

Commit

Permalink
fix: codeintel: Buffers with only one token should not cause errors a…
Browse files Browse the repository at this point in the history
…nymore - fixes #796

rn=

(integrated from master branch change 9.2.1-682-gf1b2d39 by Mitchell <mitchellb@activestate.com>)
  • Loading branch information
mitchell-as committed Nov 19, 2015
1 parent b82263c commit 78479ee
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/codeintel/lib/codeintel2/accessor.py
Expand Up @@ -172,6 +172,8 @@ def _token_at_pos(self, pos):
#XXX Locality of reference should offer an optimization here.
# Binary search for appropriate token.
lower, upper = 0, len(self.tokens) # [lower-limit, upper-limit)
if upper == 1:
return self.tokens[0]
# This being a binary search, we should have a maximum of log2(upper)
# iterations. Enforce that in case we have an issue and hit an infinite
# loop.
Expand Down

0 comments on commit 78479ee

Please sign in to comment.