File tree Expand file tree Collapse file tree 2 files changed +14
-4
lines changed Expand file tree Collapse file tree 2 files changed +14
-4
lines changed Original file line number Diff line number Diff line change @@ -31,7 +31,6 @@ function Question:get_snippet()
31
31
)
32
32
end
33
33
34
- --- @private
35
34
function Question :create_file ()
36
35
local lang = utils .get_lang (self .lang )
37
36
local alt = lang .alt and (" ." .. lang .alt ) or " "
@@ -180,17 +179,28 @@ function Question:lines()
180
179
return table.concat (lines , " \n " , start_i , end_i )
181
180
end
182
181
182
+ --- @param self lc.ui.Question
183
183
--- @param lang lc.lang
184
184
Question .change_lang = vim .schedule_wrap (function (self , lang )
185
+ local old_lang = self .lang
185
186
self .lang = lang
186
- self :create_file ()
187
187
188
- local new_bufnr = vim .fn .bufadd (self . file : absolute ())
188
+ local new_bufnr = vim .fn .bufadd (self : create_file ())
189
189
if new_bufnr ~= 0 then
190
+ local bufloaded = vim .fn .bufloaded (new_bufnr )
191
+
190
192
vim .api .nvim_win_set_buf (self .winid , new_bufnr )
193
+
194
+ vim .api .nvim_buf_set_option (self .bufnr , " buflisted" , false )
195
+ vim .api .nvim_buf_set_option (new_bufnr , " buflisted" , true )
196
+
191
197
self .bufnr = new_bufnr
198
+ if bufloaded == 0 then --
199
+ utils .exec_hooks (" LeetQuestionNew" , self )
200
+ end
192
201
else
193
202
log .error (" Changing language failed" )
203
+ self .lang = old_lang
194
204
end
195
205
end )
196
206
Original file line number Diff line number Diff line change @@ -10,7 +10,7 @@ function leetcode.should_skip(on_vimenter)
10
10
if on_vimenter then
11
11
if vim .fn .argc () ~= 1 then return true end
12
12
13
- local usr_arg , arg = vim .fn .argv ()[1 ], config . user . arg
13
+ local usr_arg , arg = config . user . arg , vim .fn .argv ()[1 ]
14
14
if usr_arg ~= arg then return true end
15
15
16
16
local lines = vim .api .nvim_buf_get_lines (0 , 0 , - 1 , true )
You can’t perform that action at this time.
0 commit comments