Skip to content

Commit

Permalink
fix: move end of doc pos to last line. Fixes #151
Browse files Browse the repository at this point in the history
  • Loading branch information
folke committed Jun 23, 2023
1 parent 2af0dd9 commit cb4da04
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions lua/trouble/view.lua
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ end

function View:set_option(name, value, win)
if win then
return vim.api.nvim_set_option_value(name, value, { win = self.win, scope = 'local' })
return vim.api.nvim_set_option_value(name, value, { win = self.win, scope = "local" })
else
return vim.api.nvim_set_option_value(name, value, { buf = self.buf })
end
Expand Down Expand Up @@ -484,7 +484,10 @@ function View:_preview()

if item.is_file ~= true then
vim.api.nvim_win_set_buf(self.parent, item.bufnr)
vim.api.nvim_win_set_cursor(self.parent, { item.start.line + 1, item.start.character })
local pos = { item.start.line + 1, item.start.character }
local line_count = vim.api.nvim_buf_line_count(item.bufnr)
pos[1] = math.min(pos[1], line_count)
vim.api.nvim_win_set_cursor(self.parent, pos)

vim.api.nvim_buf_call(item.bufnr, function()
-- Center preview line on screen and open enough folds to show it
Expand Down

0 comments on commit cb4da04

Please sign in to comment.