File tree Expand file tree Collapse file tree 2 files changed +16
-23
lines changed
Expand file tree Collapse file tree 2 files changed +16
-23
lines changed Original file line number Diff line number Diff line change @@ -73,28 +73,6 @@ function ConsoleLayout:set_keymaps(keymaps)
7373 end
7474end
7575
76- function ConsoleLayout :open_url ()
77- local command
78- local p = io.popen (" uname" )
79- local os_name
80-
81- if p then
82- os_name = p :read (" *l" )
83- p :close ()
84- end
85-
86- if os_name == " Linux" then
87- command = string.format (" xdg-open '%s'" , self .question .cache .link )
88- elseif os_name == " Darwin" then
89- command = string.format (" open '%s'" , self .question .cache .link )
90- else
91- -- Fallback to Windows if uname is not available or does not match Linux/Darwin.
92- command = string.format (" start \"\" \" %s\" " , self .question .cache .link )
93- end
94-
95- os.execute (command )
96- end
97-
9876--- @param parent lc.ui.Question
9977function ConsoleLayout :init (parent )
10078 self .question = parent
Original file line number Diff line number Diff line change @@ -250,7 +250,22 @@ function cmd.open()
250250 local utils = require (" leetcode.utils" )
251251 utils .auth_guard ()
252252 local q = utils .curr_question ()
253- if q then q .console :open_url () end
253+
254+ if q then
255+ local command
256+ local os_name = vim .loop .os_uname ().sysname
257+
258+ if os_name == " Linux" then
259+ command = string.format (" xdg-open '%s'" , q .cache .link )
260+ elseif os_name == " Darwin" then
261+ command = string.format (" open '%s'" , q .cache .link )
262+ else
263+ -- Fallback to Windows if uname is not available or does not match Linux/Darwin.
264+ command = string.format (" start \"\" \" %s\" " , q .cache .link )
265+ end
266+
267+ vim .cmd (" !" .. command )
268+ end
254269end
255270
256271function cmd .fix ()
You can’t perform that action at this time.
0 commit comments