Skip to content

Commit

Permalink
fix: dont pass content around, just bufnr
Browse files Browse the repository at this point in the history
  • Loading branch information
tris203 committed May 3, 2024
1 parent 7eacf6f commit b940437
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 8 deletions.
2 changes: 1 addition & 1 deletion lua/precognition/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ end
---@return Precognition.GutterHints
local function build_gutter_hints(buf)
local gutter_hints = {
["G"] = vm.file_end(vim.api.nvim_buf_get_lines(buf, 0, -1, false)),
["G"] = vm.file_end(vim.api.nvim_get_current_buf()),
["gg"] = vm.file_start(),
["{"] = vm.prev_paragraph_line(vim.api.nvim_get_current_buf()),
["}"] = vm.next_paragraph_line(vim.api.nvim_get_current_buf()),
Expand Down
6 changes: 3 additions & 3 deletions lua/precognition/vertical_motions.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ function M.file_start()
return 1
end

---@param lines table
---@param bufnr integer
---@return integer
function M.file_end(lines)
return #lines
function M.file_end(bufnr)
return vim.api.nvim_buf_line_count(bufnr)
end

---@param buf integer
Expand Down
6 changes: 2 additions & 4 deletions tests/precognition/vertical_motions_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,7 @@ describe("gutter motion locations", function()
vim.api.nvim_set_current_buf(testBuf)
vim.api.nvim_win_set_cursor(0, { 1, 1 })

local lines = vim.api.nvim_buf_get_lines(testBuf, 0, -1, false)
local end_ = vm.file_end(lines)
local end_ = vm.file_end(testBuf)
eq(1, end_)
eq(vim.api.nvim_buf_line_count(testBuf), end_)
end)
Expand All @@ -59,8 +58,7 @@ describe("gutter motion locations", function()
vim.api.nvim_set_current_buf(testBuf)
vim.api.nvim_win_set_cursor(0, { 4, 0 })

local lines = vim.api.nvim_buf_get_lines(testBuf, 0, -1, false)
local end_ = vm.file_end(lines)
local end_ = vm.file_end(testBuf)
eq(8, end_)
eq(vim.api.nvim_buf_line_count(testBuf), end_)
end)
Expand Down

0 comments on commit b940437

Please sign in to comment.