Skip to content

Commit 7358e53

Browse files
tenfyzhongianding1
authored andcommitted
update the problem state after submitted
1 parent ef53634 commit 7358e53

File tree

2 files changed

+28
-1
lines changed

2 files changed

+28
-1
lines changed

autoload/leetcode.vim

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1069,6 +1069,7 @@ function! s:ShowRunResultInPreview(result) abort
10691069
hi! link lcWarning lcFailure
10701070

10711071
execute saved_winnr . 'wincmd w'
1072+
call <SID>UpdateSubmitState(a:result)
10721073
endfunction
10731074

10741075
function! s:CheckRunCodeTask(timer) abort
@@ -1295,3 +1296,29 @@ function! s:FormatIntoColumns(words) abort
12951296

12961297
return lines
12971298
endfunction
1299+
1300+
function! s:UpdateSubmitState(result)
1301+
let state = '?'
1302+
if a:result['state'] == 'Accepted'
1303+
let state = 'X'
1304+
endif
1305+
let buffers = filter(range(1, bufnr('$')), 'buflisted(v:val)')
1306+
for b in buffers
1307+
let name = bufname(b)
1308+
if name !~ 'leetcode:\/\/\/problems'
1309+
continue
1310+
endif
1311+
1312+
let problems = getbufvar(b, 'leetcode_downloaded_problems')
1313+
if type(problems) != 3
1314+
continue
1315+
endif
1316+
1317+
for problem in problems
1318+
if problem['title'] == a:result['title']
1319+
let problem['state'] = state
1320+
break
1321+
endif
1322+
endfor
1323+
endfor
1324+
endfunction

plugin/leetcode.vim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ if !exists('g:leetcode_debug')
2424
let g:leetcode_debug = 0
2525
endif
2626

27-
command! -nargs=0 LeetCodeList call leetcode#ListProblems('norefresh')
27+
command! -nargs=0 LeetCodeList call leetcode#ListProblems('redraw')
2828
command! -nargs=0 LeetCodeReset call leetcode#ResetSolution(0)
2929
command! -nargs=0 LeetCodeTest call leetcode#TestSolution()
3030
command! -nargs=0 LeetCodeSubmit call leetcode#SubmitSolution()

0 commit comments

Comments
 (0)