Skip to content

feat(langs): skip language selection when only one language is configured #10

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 27, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions lua/codecompanion/_extensions/gitcommit/langs.lua
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@ function M.select_lang(callback)
return
end

-- If only one language is configured, use it directly
if #_langs == 1 then
callback(_langs[1])
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

To ensure consistent behavior, it's recommended to always invoke callbacks asynchronously. Wrap the direct callback invocation in vim.schedule() to avoid unexpected behavior due to synchronous execution in some code paths.

    vim.schedule(function()
      callback(_langs[1])
    end)

return
end

vim.ui.select(_langs, {
prompt = "Select language:",
format_item = function(item)
Expand Down