Skip to content

Commit

Permalink
fix: make watchman scanner work with path argument
Browse files Browse the repository at this point in the history
Although the wisdom of making heavy use of this functionality is dubious
(because as you add more watches to Watchman, the slower it gets,
especially in the case of nested projects under a shared root, if my
experience with running the benchmarks is anything to be believed).
  • Loading branch information
wincent committed Sep 5, 2022
1 parent aef4184 commit c7020a4
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
13 changes: 13 additions & 0 deletions data/wincent/commandt/benchmark/configs/scanner.lua
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,19 @@ return {
source = 'wincent.commandt.private.scanners.watchman',
times = times,
skip_in_ci = true,
stub_candidates = function()
assert(_G.vim == nil)
_G.vim = {
fn = {
fnamemodify = function(name, _modifier)
return name
end,
},
}
end,
unstub_candidates = function()
_G.vim = nil
end,
},
},
}
1 change: 0 additions & 1 deletion lua/wincent/commandt/private/finders/watchman.lua
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ return function(directory, options)
end
local lib = require('wincent.commandt.private.lib')
local finder = {}
-- TODO: make `directory` actually do something here
finder.scanner = require('wincent.commandt.private.scanners.watchman').scanner(directory)
finder.matcher = lib.matcher_new(finder.scanner, options)
finder.run = function(query)
Expand Down
2 changes: 1 addition & 1 deletion lua/wincent/commandt/private/scanners/watchman.lua
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ local result = nil

watchman.scanner = function(directory)
local lib = require('wincent.commandt.private.lib')
local project = watch_project(directory)
local project = watch_project(vim.fn.fnamemodify(directory, ':p'))
if project.error then
error(project.error)
-- TODO: in the future (once Watchman is more solid), degrade gracefully
Expand Down

0 comments on commit c7020a4

Please sign in to comment.