diff --git a/rope/base/codeanalyze.py b/rope/base/codeanalyze.py index 75ebd1ec8..5cfb15715 100644 --- a/rope/base/codeanalyze.py +++ b/rope/base/codeanalyze.py @@ -352,7 +352,7 @@ def count_line_indents(line): def get_string_pattern_with_prefix(prefix): longstr = r'%s"""(\\.|"(?!"")|\\\n|[^"\\])*"""' % prefix - shortstr = r'%s"(\\.|\\\n|[^"\\])*"' % prefix + shortstr = r'%s"(\\.|\\\n|[^"\\\n])*"' % prefix return '|'.join([longstr, longstr.replace('"', "'"), shortstr, shortstr.replace('"', "'")]) diff --git a/ropetest/codeanalyzetest.py b/ropetest/codeanalyzetest.py index 3b38c3273..3c65966cf 100644 --- a/ropetest/codeanalyzetest.py +++ b/ropetest/codeanalyzetest.py @@ -342,6 +342,11 @@ def test_is_on_function_keyword(self): finder = worder.Worder(code) self.assertTrue(finder.is_on_function_call_keyword(len(code) - 1)) + def test_get_word_range_with_fstring(self): + code = 'auth = 8\nmy_var = f"some value {auth}"\nprint(auth)\nother_val = "some other"' + finder = worder.Worder(code) + self.assertEqual(finder.get_word_range(45), (45, 49)) + class ScopeNameFinderTest(unittest.TestCase):