Skip to content

Commit b9f6379

Browse files
authored
Add test for check reproduce (#105)
* Fix PydocstringFormat deletes file contents if docstrings already present
1 parent c424516 commit b9f6379

File tree

2 files changed

+44
-1
lines changed

2 files changed

+44
-1
lines changed

autoload/pydocstring.vim

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,12 @@ endfunction
7676

7777
function! s:exit_callback(msg) abort
7878
unlet s:job " Needed for Neovim
79-
if len(s:results)
79+
let length = len(s:results)
80+
if length
81+
if length == 1 && s:results[0] == ''
82+
let s:results = []
83+
return
84+
endif
8085
let view = winsaveview()
8186
silent execute '% delete'
8287
call setline(1, s:results)
@@ -94,6 +99,7 @@ function! s:execute(cmd, lines, indent, start_lineno, cb, ex_cb) abort
9499
return
95100
endif
96101

102+
let s:results = []
97103
if has('nvim')
98104
if exists('s:job')
99105
call jobstop(s:job)

tests/format.vader

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,3 +39,40 @@ Expect python:
3939
:param arg2:
4040
"""
4141
pass
42+
43+
44+
Given python (Format all twice):
45+
class Foo:
46+
def foo(arg1):
47+
pass
48+
49+
50+
def bar(arg1, arg2):
51+
pass
52+
53+
54+
Execute:
55+
:PydocstringFormat
56+
:sleep 1
57+
:PydocstringFormat
58+
:sleep 1
59+
60+
Expect python:
61+
class Foo:
62+
"""Foo."""
63+
64+
def foo(arg1):
65+
"""foo.
66+
67+
:param arg1:
68+
"""
69+
pass
70+
71+
72+
def bar(arg1, arg2):
73+
"""bar.
74+
75+
:param arg1:
76+
:param arg2:
77+
"""
78+
pass

0 commit comments

Comments
 (0)