Skip to content

Commit

Permalink
Fix pattern for matching short strings
Browse files Browse the repository at this point in the history
get_string_pattern_with_prefix short str pattern modified
  • Loading branch information
hbusul committed Feb 14, 2020
1 parent 67aeb33 commit c164e56
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion rope/base/codeanalyze.py
Original file line number Diff line number Diff line change
Expand Up @@ -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('"', "'")])

Expand Down
5 changes: 5 additions & 0 deletions ropetest/codeanalyzetest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):

Expand Down

0 comments on commit c164e56

Please sign in to comment.