Skip to content

Commit 8801fc9

Browse files
committed
Fix quote choosing for special strings (r/u/b)
1 parent 4f6697d commit 8801fc9

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

indent/python.vim

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -576,8 +576,18 @@ function! GetPythonPEPFormat(lnum, count)
576576
let l:pos_start_string =
577577
\ s:SearchPosWithSkip('.', 'bcW', s:skip_string, a:lnum)
578578
call winrestview(l:better_orig_breakpointview)
579-
" Use single or double quote corresponding with start of string
580-
if getline(a:lnum)[l:pos_start_string[1]] ==# '"'
579+
" Find the type of start quote of the string
580+
" and skip charactars at the start of the string like b/u/r
581+
let l:extra_chars = 0
582+
let l:cur_char = getline(a:lnum)[l:pos_start_string[1]]
583+
while l:cur_char !=# '"' && l:cur_char !=# "'"
584+
let l:extra_chars += 1
585+
let l:cur_char = getline(a:lnum)[l:pos_start_string[1]
586+
\ + l:extra_chars]
587+
endwhile
588+
589+
590+
if l:cur_char ==# '"'
581591
call feedkeys("a\"\<CR>\"\<esc>", 'n')
582592
else
583593
call feedkeys("a'\<CR>'\<esc>", 'n')

0 commit comments

Comments
 (0)