Skip to content
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

fix: change current_provider default value to nil #88

Merged
merged 1 commit into from
Jan 13, 2025

Conversation

CALUGC
Copy link
Contributor

@CALUGC CALUGC commented Jan 13, 2025

The PR is based on issue #87
The main cause of #87 is because current_provider in state.lua is initial as { chat = "", command = ""}, when chat_handler.lua ChatHandler:get_provider first time been called, current_prov will be nil so it will try to get prov by called State:get_provider, but it will return "" by self.file_state.current_provider.chat (or self.file_state.current_provider.command) because the file_state hasn't updated yet.
And since empty string is truthy, so chat_handler.lua:78 (if not prov) will be false, then finally lead to query a provider with empty string.

One of the solutions I came up with was to simply set current_provider to { chat = nil, command = nil } when init states.

@frankroeder
Copy link
Owner

Wow @CALUGC, thank you very much for further investigation and fixing it!

@frankroeder frankroeder merged commit c529403 into frankroeder:main Jan 13, 2025
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants