Skip to content

Commit

Permalink
test: make sure that only one ripgrep invocation is started (#99)
Browse files Browse the repository at this point in the history
This only currently applies when blink finds some initial results.
Otherwise each consecutive keypress will start a new search (this is the
behavior before this commit).
  • Loading branch information
mikavilpas authored Jan 9, 2025
1 parent 23d3daf commit af33f54
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
9 changes: 7 additions & 2 deletions integration-tests/cypress/e2e/blink-ripgrep/basic_spec.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -350,8 +350,13 @@ describe("debug mode", () => {
rgbify(flavors.macchiato.colors.base.rgb),
)

// TODO should programmatically check that only one search was started,
// this will not catch all cases
cy.runLuaCode({
luaCode: `return _G.blink_ripgrep_invocations`,
}).should((result) => {
// ripgrep should only have been invoked once
expect(result.value).to.be.an("array")
expect(result.value).to.have.length(1)
})
})
})
})
Expand Down
4 changes: 4 additions & 0 deletions lua/blink-ripgrep/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,10 @@ function RgSource:get_completions(context, resolve)
if RgSource.config.debug then
command.debugify_for_shell(cmd)
require("blink-ripgrep.visualization").flash_search_prefix(prefix)
-- selene: allow(global_usage)
_G.blink_ripgrep_invocations = _G.blink_ripgrep_invocations or {}
-- selene: allow(global_usage)
table.insert(_G.blink_ripgrep_invocations, cmd)
end
end

Expand Down

0 comments on commit af33f54

Please sign in to comment.