Skip to content

Commit c86e326

Browse files
committed
refactor: quick return
1 parent 33f28e3 commit c86e326

1 file changed

Lines changed: 10 additions & 14 deletions

File tree

lua/telescope/_extensions/gh_actions.lua

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -73,22 +73,18 @@ A.gh_issue_insert = function(prompt_bufnr)
7373
end
7474

7575
A.gh_insert_markdown_link = function(prompt_bufnr)
76+
if not (vim.api.nvim_buf_get_option(vim.api.nvim_get_current_buf(), "modifiable")) then
77+
return
78+
end
7679
local issue_number = close_telescope_prompt(prompt_bufnr)
77-
local output = utils.get_os_command_output {
78-
"gh",
79-
"issue",
80-
"view",
81-
issue_number,
82-
"--json",
83-
"number,title,url",
84-
"--template",
85-
'{{printf "%.0f\\x1f%s\\x1f%s" .number .title .url}}',
80+
local text = utils.get_os_command_output {
81+
"gh", "issue", "view", issue_number,
82+
"--json", "number,title,url",
83+
"--template", '{{printf "%.0f\\x1f%s\\x1f%s" .number .title .url}}',
8684
}
87-
if output then
88-
local tmp_table = vim.split(output[1], "\x1f")
89-
if vim.api.nvim_buf_get_option(vim.api.nvim_get_current_buf(), "modifiable") then
90-
vim.api.nvim_put({ string.format("[%s (#%s)](%s)", tmp_table[2], tmp_table[1], tmp_table[3]) }, "b", true, true)
91-
end
85+
if text then
86+
local tmp_table = vim.split(text[1], "\x1f")
87+
vim.api.nvim_put({ string.format("[%s (#%s)](%s)", tmp_table[2], tmp_table[1], tmp_table[3]) }, "b", true, true)
9288
end
9389
end
9490

0 commit comments

Comments
 (0)