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)
| 110 | |
| 111 | |
| 112 | def 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_]*)[.]") |