File tree Expand file tree Collapse file tree 8 files changed +19
-16
lines changed
Expand file tree Collapse file tree 8 files changed +19
-16
lines changed Original file line number Diff line number Diff line change 6767function ConsoleLayout :run (submit )
6868 if config .user .console .open_on_runcode then
6969 self :show ()
70- self .result :focus ()
7170 end
71+
72+ self .result :focus ()
73+
7274 Runner :init (self .question ):run (submit )
7375end
7476
Original file line number Diff line number Diff line change @@ -31,10 +31,9 @@ function Popup:_buf_destory()
3131end
3232
3333function Popup :focus ()
34- if not vim .api .nvim_win_is_valid (self .winid ) then
35- return
34+ if self . winid and vim .api .nvim_win_is_valid (self .winid ) then
35+ vim . api . nvim_set_current_win ( self . winid )
3636 end
37- vim .api .nvim_set_current_win (self .winid )
3837end
3938
4039function Popup :clear () --
Original file line number Diff line number Diff line change 3535
3636--- @param code ? string
3737function Question :set_lines (code )
38- if not vim .api .nvim_buf_is_valid (self .bufnr ) then
38+ if not ( self . bufnr and vim .api .nvim_buf_is_valid (self .bufnr ) ) then
3939 return
4040 end
4141
@@ -164,7 +164,7 @@ function Question:_unmount()
164164 self .console :unmount ()
165165 self .description :unmount ()
166166
167- if vim .api .nvim_buf_is_valid (self .bufnr ) then
167+ if self . bufnr and vim .api .nvim_buf_is_valid (self .bufnr ) then
168168 vim .api .nvim_buf_delete (self .bufnr , { force = true , unload = false })
169169 end
170170
@@ -177,7 +177,7 @@ function Question:_unmount()
177177end
178178
179179function Question :unmount ()
180- if vim .api .nvim_win_is_valid (self .winid ) then
180+ if self . winid and vim .api .nvim_win_is_valid (self .winid ) then
181181 vim .api .nvim_win_close (self .winid , true )
182182 end
183183end
Original file line number Diff line number Diff line change @@ -24,7 +24,7 @@ function Renderer:draw(component)
2424 self .bufnr = component .bufnr
2525 self .winid = component .winid
2626
27- if not vim .api .nvim_buf_is_valid (self .bufnr ) then
27+ if not ( self . bufnr and vim .api .nvim_buf_is_valid (self .bufnr ) ) then
2828 return
2929 end
3030
Original file line number Diff line number Diff line change @@ -56,7 +56,7 @@ function Menu:autocmds()
5656end
5757
5858function Menu :cursor_move ()
59- if not self .winid or not api .nvim_win_is_valid (self .winid ) then
59+ if not ( self .winid and api .nvim_win_is_valid (self .winid ) ) then
6060 return
6161 end
6262
Original file line number Diff line number Diff line change 5858
5959--- @param layout lc.ui.Renderer
6060function utils .win_width (layout )
61- if not vim .api .nvim_win_is_valid (layout .winid ) then
61+ if not ( layout . winid and vim .api .nvim_win_is_valid (layout .winid ) ) then
6262 return 0
6363 end
6464 return vim .api .nvim_win_get_width (layout .winid )
Original file line number Diff line number Diff line change @@ -125,9 +125,6 @@ cmd.expire = vim.schedule_wrap(function()
125125 end )
126126end )
127127
128- --- Merge configurations into default configurations and set it as user configurations.
129- ---
130- -- @param theme lc-db.Theme
131128function cmd .qot ()
132129 require (" leetcode.utils" ).auth_guard ()
133130
@@ -196,7 +193,10 @@ function cmd.yank()
196193 return
197194 end
198195
199- if api .nvim_buf_is_valid (q .bufnr ) and api .nvim_win_is_valid (q .winid ) then
196+ if
197+ (q .bufnr and api .nvim_buf_is_valid (q .bufnr ))
198+ and (q .winid and api .nvim_win_is_valid (q .winid ))
199+ then
200200 api .nvim_set_current_win (q .winid )
201201 api .nvim_set_current_buf (q .bufnr )
202202
@@ -388,7 +388,7 @@ function cmd.inject()
388388 return
389389 end
390390
391- if api .nvim_buf_is_valid (q .bufnr ) then
391+ if q . bufnr and api .nvim_buf_is_valid (q .bufnr ) then
392392 local start_i , end_i = q :range (true )
393393 local not_found = {}
394394
Original file line number Diff line number Diff line change @@ -128,7 +128,9 @@ function utils.translate(content, translated_content)
128128end
129129
130130function utils .auth_guard ()
131- assert (config .auth .is_signed_in , " User not logged-in" )
131+ if not config .auth .is_signed_in then
132+ error (" User not logged-in" , 0 )
133+ end
132134end
133135
134136function utils .norm_ins (str )
You can’t perform that action at this time.
0 commit comments