Skip to content

Commit b55d5ba

Browse files
committed
Fix issues with multiple string patterns on one line
1 parent 1ba62c6 commit b55d5ba

File tree

2 files changed

+25
-1
lines changed

2 files changed

+25
-1
lines changed

autoload/sj/python.vim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -394,7 +394,7 @@ function! sj#python#SplitString()
394394
return 0
395395
endif
396396

397-
let string_pattern = '\(\%(^\|[^\\]\)\zs\([''"]\)\).\{-}[^\\]\+\2'
397+
let string_pattern = '\%(^\|[^\\]\)\zs\([''"]\+\).\{-}[^\\]\1'
398398
let empty_string_pattern = '\%(''''\|""\)'
399399

400400
let lineno = line('.')

spec/plugin/python_spec.rb

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -562,5 +562,29 @@ def example():
562562
""", three)
563563
EOF
564564
end
565+
566+
it "handles multiple strings on one line " do
567+
set_file_contents 'string = "foo" + "bar"'
568+
569+
vim.search '"foo'
570+
split
571+
572+
assert_file_contents <<~EOF
573+
string = """
574+
foo
575+
""" + "bar"
576+
EOF
577+
join
578+
579+
vim.search '"bar'
580+
split
581+
582+
assert_file_contents <<~EOF
583+
string = "foo" + """
584+
bar
585+
"""
586+
EOF
587+
join
588+
end
565589
end
566590
end

0 commit comments

Comments
 (0)