Skip to content

Commit 75937c8

Browse files
committed
Simplify convert_to_python more
1 parent 78cc8ae commit 75937c8

1 file changed

Lines changed: 11 additions & 15 deletions

File tree

lua/pyrepl/jupytext.lua

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -79,25 +79,21 @@ function M.convert_to_python(buf)
7979
choices[#choices + 1] = "open existing file"
8080
end
8181

82-
local function on_choice_yes()
83-
local text = get_buf_text(buf)
84-
if #text == 0 then
85-
text = template
86-
end
87-
88-
local ok, error = pcall(convert_text, text, name, false)
89-
if not ok then
90-
vim.notify(message .. "failed to run jupytext: " .. error, vim.log.levels.ERROR)
91-
else
92-
edit_relative(name)
93-
end
94-
end
95-
9682
vim.ui.select(choices, {
9783
prompt = string.format('Convert notebook to "%s"?', name),
9884
}, function(choice)
9985
if choice == "yes" then
100-
on_choice_yes()
86+
local text = get_buf_text(buf)
87+
if #text == 0 then
88+
text = template
89+
end
90+
91+
local ok, error = pcall(convert_text, text, name, false)
92+
if not ok then
93+
vim.notify(message .. "failed to run jupytext: " .. error, vim.log.levels.ERROR)
94+
else
95+
edit_relative(name)
96+
end
10197
elseif choice == "open existing file" then
10298
edit_relative(name)
10399
end

0 commit comments

Comments
 (0)