MCPcopy Index your code
hub / github.com/bpython/bpython / current_string

Function current_string

bpython/line.py:112–122  ·  view source on GitHub ↗

If inside a string of nonzero length, return the string (excluding quotes) Weaker than bpython.Repl's current_string, because that checks that a string is a string based on previous lines in the buffer.

(cursor_offset: int, line: str)

Source from the content-addressed store, hash-verified

110
111
112def current_string(cursor_offset: int, line: str) -> LinePart | None:
113 """If inside a string of nonzero length, return the string (excluding
114 quotes)
115
116 Weaker than bpython.Repl's current_string, because that checks that a
117 string is a string based on previous lines in the buffer."""
118 for m in _current_string_re.finditer(line):
119 i = 3 if m.group(3) else 4
120 if m.start(i) <= cursor_offset <= m.end(i):
121 return LinePart(m.start(i), m.end(i), m.group(i))
122 return None
123
124
125_current_object_re = LazyReCompile(r"([\w_][\w0-9_]*)[.]")

Callers

nothing calls this directly

Calls 3

LinePartClass · 0.85
finditerMethod · 0.80
startMethod · 0.80

Tested by

no test coverage detected