Skip to content
This repository has been archived by the owner on Jul 4, 2024. It is now read-only.

Commit

Permalink
style: run stylua formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisgrieser committed Jun 2, 2024
1 parent 6a2b15b commit cd2a1b9
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 12 deletions.
4 changes: 2 additions & 2 deletions lua/alt-substitute/process-parameters.lua
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ function M.splitByUnescapedSlash(str)
if vim.endswith(prevMatch, "\\") then
splitStr[#splitStr] = prevMatch:sub(1, -2) .. "/" .. match
else
table.insert(splitStr, match)
table.insert(splitStr, match)
end
end

Expand All @@ -39,7 +39,7 @@ end
---@return string flags
function M.process(opts, curBufNum)
local params = M.splitByUnescapedSlash(opts.args)
local toSearch = params[1] or ""
local toSearch = params[1] or ""
local toReplace = params[2] or ""
local flags = params[3] or ""

Expand Down
2 changes: 1 addition & 1 deletion lua/alt-substitute/substitution.lua
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ function M.confirm(opts, showNotification, regexFlavor)
vim.notify("Search string is empty.", warn)
return
elseif invalidPattern then
vim.notify('Invalid pattern used.', warn)
vim.notify("Invalid pattern used.", warn)
return
end
if invalidFlagsUsed then
Expand Down
4 changes: 1 addition & 3 deletions tests/calc_highlight_positions_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ describe("calculate highlight positions: ", function()
it("Search & Replace (Base)", function()
local params = { "foobar", "1234", "" }
local expected = { {}, { { startPos = 1, endPos = 4 } }, {}, {} }
assert.same(expected, calc(params))
assert.same(expected, calc(params))
end)
it("only search", function()
local params = { "mod", "", "" }
Expand Down Expand Up @@ -63,6 +63,4 @@ describe("calculate highlight positions: ", function()
local expected = { {}, { { startPos = 1, endPos = 4 } }, {}, {} }
assert.same(expected, calc(params))
end)


end)
11 changes: 5 additions & 6 deletions tests/parameter_processing_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,31 +4,30 @@ describe("parameter processing: ", function()
it("Standard Case", function()
local input = "/search/repl/g"
local params = splitByUnescapedSlash(input)
assert.same({"search", "repl", "g"}, params)
assert.same({ "search", "repl", "g" }, params)
end)

it("escaping the slash", function()
local input = [[/some\/path/repl/g]]
local params = splitByUnescapedSlash(input)
assert.same({"some/path", "repl", "g"}, params)
assert.same({ "some/path", "repl", "g" }, params)
end)

it("empty replacement", function()
local input = [[/foobar//i]]
local params = splitByUnescapedSlash(input)
assert.same({"foobar", "", "i"}, params)
assert.same({ "foobar", "", "i" }, params)
end)

it("no flags", function()
local input = [[/foo/bar/]]
local params = splitByUnescapedSlash(input)
assert.same({"foo", "bar"}, params)
assert.same({ "foo", "bar" }, params)
end)

it("only flags", function()
local input = [[///g]]
local params = splitByUnescapedSlash(input)
assert.same({"", "", "g"}, params)
assert.same({ "", "", "g" }, params)
end)

end)

0 comments on commit cd2a1b9

Please sign in to comment.