File tree Expand file tree Collapse file tree 1 file changed +8
-11
lines changed
Expand file tree Collapse file tree 1 file changed +8
-11
lines changed Original file line number Diff line number Diff line change 1111from .lazyre import LazyReCompile
1212
1313LinePart = namedtuple ("LinePart" , ["start" , "stop" , "word" ])
14-
1514current_word_re = LazyReCompile (r"(?<![)\]\w_.])" r"([\w_][\w0-9._]*[(]?)" )
1615
1716
1817def current_word (cursor_offset : int , line : str ) -> Optional [LinePart ]:
1918 """the object.attribute.attribute just before or under the cursor"""
20- pos = cursor_offset
21- start = pos
22- end = pos
19+ start = cursor_offset
20+ end = cursor_offset
2321 word = None
2422 for m in current_word_re .finditer (line ):
25- if m .start (1 ) < pos <= m .end (1 ):
23+ if m .start (1 ) < cursor_offset <= m .end (1 ):
2624 start = m .start (1 )
2725 end = m .end (1 )
2826 word = m .group (1 )
@@ -82,12 +80,11 @@ def current_object(cursor_offset: int, line: str) -> Optional[LinePart]:
8280 if match is None :
8381 return None
8482 start , end , word = match
85- s = ""
86- for m in current_object_re .finditer (word ):
87- if m .end (1 ) + start < cursor_offset :
88- if s :
89- s += "."
90- s += m .group (1 )
83+ s = "." .join (
84+ m .group (1 )
85+ for m in current_object_re .finditer (word )
86+ if m .end (1 ) + start < cursor_offset
87+ )
9188 if not s :
9289 return None
9390 return LinePart (start , start + len (s ), s )
You can’t perform that action at this time.
0 commit comments