Skip to content

Commit 02a4c41

Browse files
committed
fix bug in testing with one string as param
- "\"param\"" was not working and it needed to be '""param""' to make it work, possibly becoz of a change of the leetcode graphql api
1 parent 63feeb5 commit 02a4c41

File tree

3 files changed

+9
-6
lines changed

3 files changed

+9
-6
lines changed

autoload/leetcode/testCode.vim

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,13 @@ fu! leetcode#testCode#testCode(...)
33
try
44
let test_cmd = 'leetcode test "' .expand('%:p') .'"'
55
let Q_fullname = expand('%:p:h:t')
6-
if !a:1 && len(a:2)
7-
let test_cmd .= ' -t "' .substitute(a:2, '"', '\\"', 'g') .'"'
8-
elseif !a:1 && len(a:2) == 0 && leetcode#utils#accessFiles#lastFailCaseExists(Q_fullname)
9-
let test_cmd .= ' -t "' .escape(leetcode#utils#accessFiles#readLastFailCase(Q_fullname), '"') .'"'
6+
if !a:1
7+
if len(a:2)
8+
let test_case = a:2
9+
elseif len(a:2) == 0 && leetcode#utils#accessFiles#lastFailCaseExists(Q_fullname)
10+
let test_case = leetcode#utils#accessFiles#readLastFailCase(Q_fullname)
11+
endif
12+
let test_cmd .= " -t '\"" .substitute(test_case, "'", "'\"'\"'", 'g') ."\"'"
1013
en
1114
cal leetcode#utils#judgeCode#test(test_cmd, Q_fullname)
1215
cat /.*/ | echoe '[' .g:leetcode_name .'] ' .v:exception | endt

autoload/leetcode/utils/accessFiles.vim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ endfu
191191

192192
fu! leetcode#utils#accessFiles#appendText(file_path, text)
193193
"" Append text in this way but not in a Vim way to avoid pollution to buffer, jumplist, etc
194-
cal system("echo '" .a:text ."' >> '" .a:file_path ."'")
194+
cal system("echo '" .substitute(a:text, "'", "'\"'\"'", 'g') ."' >> '" .a:file_path ."'")
195195
endfu
196196

197197
fu! leetcode#utils#accessFiles#readFile(file_path)

plugin/leetcode.vim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
"" Version: 0.6.0
1+
"" Version: 0.6.1
22
"" Description:
33
"" This is a leetcode question and code file manager. It allows a quick
44
"" download, load, test and submission of leetcode questions. The file

0 commit comments

Comments
 (0)