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()
3131 )
3232end
3333
34- --- @private
3534function Question :create_file ()
3635 local lang = utils .get_lang (self .lang )
3736 local alt = lang .alt and (" ." .. lang .alt ) or " "
@@ -180,17 +179,28 @@ function Question:lines()
180179 return table.concat (lines , " \n " , start_i , end_i )
181180end
182181
182+ --- @param self lc.ui.Question
183183--- @param lang lc.lang
184184Question .change_lang = vim .schedule_wrap (function (self , lang )
185+ local old_lang = self .lang
185186 self .lang = lang
186- self :create_file ()
187187
188- local new_bufnr = vim .fn .bufadd (self . file : absolute ())
188+ local new_bufnr = vim .fn .bufadd (self : create_file ())
189189 if new_bufnr ~= 0 then
190+ local bufloaded = vim .fn .bufloaded (new_bufnr )
191+
190192 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+
191197 self .bufnr = new_bufnr
198+ if bufloaded == 0 then --
199+ utils .exec_hooks (" LeetQuestionNew" , self )
200+ end
192201 else
193202 log .error (" Changing language failed" )
203+ self .lang = old_lang
194204 end
195205end )
196206
Original file line number Diff line number Diff line change @@ -10,7 +10,7 @@ function leetcode.should_skip(on_vimenter)
1010 if on_vimenter then
1111 if vim .fn .argc () ~= 1 then return true end
1212
13- local usr_arg , arg = vim .fn .argv ()[1 ], config . user . arg
13+ local usr_arg , arg = config . user . arg , vim .fn .argv ()[1 ]
1414 if usr_arg ~= arg then return true end
1515
1616 local lines = vim .api .nvim_buf_get_lines (0 , 0 , - 1 , true )
You can’t perform that action at this time.
0 commit comments