Skip to content

Commit

Permalink
mp.input: tidy up coroutine code
Browse files Browse the repository at this point in the history
  • Loading branch information
CogentRedTester committed Nov 16, 2024
1 parent cc2807c commit 695655a
Showing 1 changed file with 8 additions and 12 deletions.
20 changes: 8 additions & 12 deletions addons/find.lua
Original file line number Diff line number Diff line change
Expand Up @@ -36,22 +36,18 @@ local function main(key, state, co)
if key.name == "find/find" then text = "Find: enter search string"
else text = "Find: enter advanced search string" end

local query, error = nil, nil
if input_loaded then
query = coroutine.yield(
input.get({
prompt = text .. "\n>",
id = "find",
submit = fb.coroutine.callback(),
})
)
input.terminate()
input.get({
prompt = text .. "\n>",
id = "find",
submit = fb.coroutine.callback(),
})
elseif user_input_loaded then
query, error = coroutine.yield(
user_input.get_user_input( fb.coroutine.callback(), { text = text, id = "find", replace = true } )
)
user_input.get_user_input( fb.coroutine.callback(), { text = text, id = "find", replace = true } )
end

local query, error = coroutine.yield()
if input_loaded then input.terminate() end
if not query then return msg.debug(error) end

-- allow the directory to be changed before this point
Expand Down

0 comments on commit 695655a

Please sign in to comment.