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 67
67
function ConsoleLayout :run (submit )
68
68
if config .user .console .open_on_runcode then
69
69
self :show ()
70
- self .result :focus ()
71
70
end
71
+
72
+ self .result :focus ()
73
+
72
74
Runner :init (self .question ):run (submit )
73
75
end
74
76
Original file line number Diff line number Diff line change @@ -31,10 +31,9 @@ function Popup:_buf_destory()
31
31
end
32
32
33
33
function 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 )
36
36
end
37
- vim .api .nvim_set_current_win (self .winid )
38
37
end
39
38
40
39
function Popup :clear () --
Original file line number Diff line number Diff line change 35
35
36
36
--- @param code ? string
37
37
function 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
39
39
return
40
40
end
41
41
@@ -164,7 +164,7 @@ function Question:_unmount()
164
164
self .console :unmount ()
165
165
self .description :unmount ()
166
166
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
168
168
vim .api .nvim_buf_delete (self .bufnr , { force = true , unload = false })
169
169
end
170
170
@@ -177,7 +177,7 @@ function Question:_unmount()
177
177
end
178
178
179
179
function 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
181
181
vim .api .nvim_win_close (self .winid , true )
182
182
end
183
183
end
Original file line number Diff line number Diff line change @@ -24,7 +24,7 @@ function Renderer:draw(component)
24
24
self .bufnr = component .bufnr
25
25
self .winid = component .winid
26
26
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
28
28
return
29
29
end
30
30
Original file line number Diff line number Diff line change @@ -56,7 +56,7 @@ function Menu:autocmds()
56
56
end
57
57
58
58
function 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
60
60
return
61
61
end
62
62
Original file line number Diff line number Diff line change 58
58
59
59
--- @param layout lc.ui.Renderer
60
60
function 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
62
62
return 0
63
63
end
64
64
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()
125
125
end )
126
126
end )
127
127
128
- --- Merge configurations into default configurations and set it as user configurations.
129
- ---
130
- -- @param theme lc-db.Theme
131
128
function cmd .qot ()
132
129
require (" leetcode.utils" ).auth_guard ()
133
130
@@ -196,7 +193,10 @@ function cmd.yank()
196
193
return
197
194
end
198
195
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
200
200
api .nvim_set_current_win (q .winid )
201
201
api .nvim_set_current_buf (q .bufnr )
202
202
@@ -388,7 +388,7 @@ function cmd.inject()
388
388
return
389
389
end
390
390
391
- if api .nvim_buf_is_valid (q .bufnr ) then
391
+ if q . bufnr and api .nvim_buf_is_valid (q .bufnr ) then
392
392
local start_i , end_i = q :range (true )
393
393
local not_found = {}
394
394
Original file line number Diff line number Diff line change @@ -128,7 +128,9 @@ function utils.translate(content, translated_content)
128
128
end
129
129
130
130
function 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
132
134
end
133
135
134
136
function utils .norm_ins (str )
You can’t perform that action at this time.
0 commit comments