Skip to content

Commit

Permalink
fix: remove non-dedicated header modification
Browse files Browse the repository at this point in the history
  • Loading branch information
theKnightsOfRohan committed Jan 26, 2025
1 parent 4264ca5 commit 8cb0d4d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
5 changes: 2 additions & 3 deletions lua/hexer/parser.lua
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ function M.parse_input(input)
if #input == 1 then return { M._parse_from_int(input:byte(1)) } end

local head, tail = 1, input:len()
if input:sub(1, 1) == '0' then head = head + 2 end
local orig_head = head


Expand Down Expand Up @@ -110,7 +109,7 @@ function M._itob(input)
return result
end

---Checks if the string has the given number format header and returns the start of the value if it does, otherwise 0
---Checks if the string has the given number format header and returns the start of the value if it does, otherwise 1
---@param str string
---@param header string[] the list of single-character format specifiers
---@return integer
Expand All @@ -126,7 +125,7 @@ function M._check_header(str, header)
end
end

return 0
return 1
end

---Create a HexerChar from a given integer
Expand Down
8 changes: 4 additions & 4 deletions lua/hexer/tests/parser_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ describe("Parser", function()

val_pos = Parser._check_header(strs[1], headers[2])

assert(val_pos == 0,
("String %s with headers %s expected pos %s but got %s"):format(strs[1], vim.inspect(headers[2]), 0, val_pos)
assert(val_pos == 1,
("String %s with headers %s expected pos %s but got %s"):format(strs[1], vim.inspect(headers[2]), 1, val_pos)
)

val_pos = Parser._check_header(strs[2], headers[1])
Expand All @@ -44,8 +44,8 @@ describe("Parser", function()

val_pos = Parser._check_header(strs[2], headers[2])

assert(val_pos == 0,
("String %s with headers %s expected pos %s but got %s"):format(strs[2], vim.inspect(headers[2]), 0, val_pos)
assert(val_pos == 1,
("String %s with headers %s expected pos %s but got %s"):format(strs[2], vim.inspect(headers[2]), 1, val_pos)
)
end)

Expand Down

0 comments on commit 8cb0d4d

Please sign in to comment.