File tree 5 files changed +17
-31
lines changed
5 files changed +17
-31
lines changed Original file line number Diff line number Diff line change @@ -48,14 +48,10 @@ function Question:set_lines(code)
48
48
end
49
49
50
50
function Question :reset_lines ()
51
- if not self .reset then
52
- return
53
- end
54
-
55
51
local new_lines = self :snippet (true ) or " "
56
52
57
53
vim .schedule (function () --
58
- log .info (" Previous code found and reseted \n To undo, simply press `u`" )
54
+ log .info (" Previous code found and reset \n To undo, simply press `u`" )
59
55
end )
60
56
61
57
self :set_lines (new_lines )
@@ -315,14 +311,12 @@ Question.change_lang = vim.schedule_wrap(function(self, lang)
315
311
end )
316
312
317
313
--- @param problem lc.cache.Question
318
- --- @param reset boolean
319
- function Question :init (problem , reset )
314
+ function Question :init (problem )
320
315
self .cache = problem
321
316
self .lang = config .lang
322
- self .reset = reset and true or false
323
317
end
324
318
325
- --- @type fun ( question : lc.cache.Question , reset ?: boolean ): lc.ui.Question
319
+ --- @type fun ( question : lc.cache.Question ): lc.ui.Question
326
320
local LeetQuestion = Question
327
321
328
322
return LeetQuestion
Original file line number Diff line number Diff line change @@ -154,11 +154,11 @@ function Menu:unmount()
154
154
155
155
require (" leetcode.command" ).q_close_all ()
156
156
157
- if self .winid and vim .api .nvim_win_is_valid (self .winid ) then
158
- vim .api .nvim_win_close (self .winid , true )
159
- end
160
-
161
157
vim .schedule (function ()
158
+ if self .winid and vim .api .nvim_win_is_valid (self .winid ) then
159
+ vim .api .nvim_win_close (self .winid , true )
160
+ end
161
+
162
162
if self .bufnr and vim .api .nvim_buf_is_valid (self .bufnr ) then
163
163
vim .api .nvim_buf_delete (self .bufnr , { force = true })
164
164
end
Original file line number Diff line number Diff line change @@ -140,7 +140,7 @@ function cmd.qot()
140
140
return log .err (err )
141
141
end
142
142
local problemlist = require (" leetcode.cache.problemlist" )
143
- Question (problemlist .get_by_title_slug (qot .title_slug ), true ):mount ()
143
+ Question (problemlist .get_by_title_slug (qot .title_slug )):mount ()
144
144
end )
145
145
end
146
146
@@ -168,7 +168,7 @@ function cmd.random_question(opts)
168
168
169
169
local item = problems .get_by_title_slug (q .title_slug ) or {}
170
170
local Question = require (" leetcode-ui.question" )
171
- Question (item , true ):mount ()
171
+ Question (item ):mount ()
172
172
end
173
173
174
174
function cmd .start_with_cmd ()
Original file line number Diff line number Diff line change 2
2
local hooks = {}
3
3
4
4
hooks [" question_enter" ] = {
5
- vim . schedule_wrap ( function (q )
5
+ function (q )
6
6
-- https://github.com/kawre/leetcode.nvim/issues/14
7
- if q .lang ~= " rust" then
8
- return
7
+ if q .lang == " rust" then
8
+ pcall (function ()
9
+ require (" rust-tools.standalone" ).start_standalone_client ()
10
+ end )
9
11
end
10
- pcall (function ()
11
- require (" rust-tools.standalone" ).start_standalone_client ()
12
- end )
13
- end ),
12
+ end ,
14
13
}
15
14
16
15
return hooks
Original file line number Diff line number Diff line change @@ -128,7 +128,7 @@ return {
128
128
}),
129
129
sorter = conf .generic_sorter (theme ),
130
130
attach_mappings = function (prompt_bufnr , map )
131
- local function mount_question ( reset )
131
+ actions . select_default : replace ( function ( )
132
132
local selection = action_state .get_selected_entry ()
133
133
if not selection then
134
134
return
@@ -140,14 +140,7 @@ return {
140
140
end
141
141
142
142
actions .close (prompt_bufnr )
143
- Question (q , reset ):mount ()
144
- end
145
-
146
- actions .select_default :replace (function ()
147
- mount_question ()
148
- end )
149
- map ({ " n" , " i" }, " <C-Enter>" , function ()
150
- mount_question (true )
143
+ Question (q ):mount ()
151
144
end )
152
145
153
146
return true
You can’t perform that action at this time.
0 commit comments