@@ -180,42 +180,26 @@ end
180
180
--- @param value ? string
181
181
--- @return nil
182
182
function M :set_option (option , value )
183
- -- Prompt user to select from predetermined choices
184
- if value then
183
+ if option .value and option .value ~= " " then -- Toggle option off when it's currently set
184
+ option .value = " "
185
+ elseif value then
185
186
option .value = value
186
187
elseif option .choices then
187
- if not option .value or option .value == " " then
188
- local eventignore = vim .o .eventignore
189
- vim .o .eventignore = " WinLeave"
190
- local choice = FuzzyFinderBuffer .new (option .choices ):open_async {
191
- prompt_prefix = option .description ,
192
- }
193
- vim .o .eventignore = eventignore
194
-
195
- if choice then
196
- option .value = choice
197
- else
198
- option .value = " "
199
- end
200
- else
201
- option .value = " "
202
- end
188
+ local eventignore = vim .o .eventignore
189
+ vim .o .eventignore = " WinLeave"
190
+ option .value = FuzzyFinderBuffer .new (option .choices ):open_async {
191
+ prompt_prefix = option .description ,
192
+ refocus_status = false ,
193
+ }
194
+ vim .o .eventignore = eventignore
203
195
elseif option .fn then
204
196
option .value = option .fn (self , option )
205
197
else
206
- local input = input .get_user_input (option .cli , {
198
+ option . value = input .get_user_input (option .cli , {
207
199
separator = " =" ,
208
200
default = option .value ,
209
201
cancel = option .value ,
210
202
})
211
-
212
- -- If the option specifies a default value, and the user set the value to be empty, defer to default value.
213
- -- This is handy to prevent the user from accidentally loading thousands of log entries by accident.
214
- if option .default and input == " " then
215
- option .value = tostring (option .default )
216
- else
217
- option .value = input
218
- end
219
203
end
220
204
221
205
state .set ({ self .state .name , option .cli }, option .value )
0 commit comments