Skip to content

Commit

Permalink
Merge pull request #235 from pablobfonseca/fix-deprecations
Browse files Browse the repository at this point in the history
fix: 0.11-nightly warnings of deprecated functions
  • Loading branch information
EpsilonKu authored May 22, 2024
2 parents 50e9660 + 2410feb commit 5690ea4
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
2 changes: 1 addition & 1 deletion lua/spectre/replace/sed.lua
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ sed.replace = function(self, value)
utils.escape_sed(value.search_text),
utils.escape_sed(value.replace_text)
)
local args = vim.tbl_flatten({
local args = utils.tbl_flatten({
self.state.args,
t_sed,
value.filename,
Expand Down
5 changes: 2 additions & 3 deletions lua/spectre/search/base.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
---@diagnostic disable: param-type-mismatch
local flatten = vim.tbl_flatten
local Job = require('plenary.job')
local log = require('spectre._log')
local MAX_LINE_CHARS = 255
Expand Down Expand Up @@ -84,7 +83,7 @@ base.on_exit = function(self, value)
end

base.search = function(self, query)
local args = flatten({
local args = utils.tbl_flatten({
-- query.search_text,
self.state.args,
})
Expand All @@ -99,7 +98,7 @@ base.search = function(self, query)

-- no more args
table.insert(args, '--')
args = flatten(args)
args = utils.tbl_flatten(args)

if query.cwd == '' then
query.cwd = nil
Expand Down
5 changes: 5 additions & 0 deletions lua/spectre/utils.lua
Original file line number Diff line number Diff line change
Expand Up @@ -216,4 +216,9 @@ M.tbl_remove_dup = function(tbl)
end
return res
end

M.tbl_flatten = function(t)
return vim.fn.has('nvim-0.11') == 1 and vim.iter(t):flatten(math.huge):totable() or vim.tbl_flatten(t)
end

return M

0 comments on commit 5690ea4

Please sign in to comment.