Skip to content

Commit

Permalink
fix: schedule stuff for async stuff?
Browse files Browse the repository at this point in the history
  • Loading branch information
gptlang committed Jul 16, 2024
1 parent 23d4d0f commit 362a381
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
10 changes: 6 additions & 4 deletions lua/CopilotChat/copilot.lua
Original file line number Diff line number Diff line change
Expand Up @@ -526,10 +526,12 @@ function Copilot:select_model(callback)
for _, model in ipairs(models) do
table.insert(selections, model['version'])
end
vim.ui.select(selections, {
prompt = 'Select a model',
}, function(choice)
callback(choice)
vim.schedule(function()
vim.ui.select(selections, {
prompt = 'Select a model',
}, function(choice)
callback(choice)
end)
end)
end,
})
Expand Down
8 changes: 5 additions & 3 deletions lua/CopilotChat/tiktoken.lua
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,11 @@ local function load_tiktoken_data(done, model)
-- Take filename after the last slash of the url
local cache_path = get_cache_path(tiktoken_url:match('.+/(.+)'))
if not file_exists(cache_path) then
curl.get(tiktoken_url, {
output = cache_path,
})
vim.schedule(function()
curl.get(tiktoken_url, {
output = cache_path,
})
end)
end

done(cache_path)
Expand Down

0 comments on commit 362a381

Please sign in to comment.