Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/documentation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ jobs:
nvim -c 'helptags doc' -c 'quit'

- name: Push Changes
uses: stefanzweifel/git-auto-commit-action@v6
uses: stefanzweifel/git-auto-commit-action@v7
with:
commit_message: "docs: Auto-generate user / API documentation + vimtags"
commit_user_name: "github-actions[bot]"
Expand Down
3 changes: 2 additions & 1 deletion lua/lua-console.lua
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,15 @@ local get_or_create_buffer = function()
vim.bo[buf].swapfile = false
vim.bo[buf].buflisted = false
vim.bo[buf].bufhidden = 'hide'
vim.bo[buf].buftype = 'nowrite'

vim.api.nvim_buf_set_name(buf, buf_name) -- the name is only needed so the buffer is picked up by Lsp with correct root

injections.set_highlighting()
vim.api.nvim_set_option_value('filetype', 'lua', { buf = buf })
vim.api.nvim_set_option_value('syntax', 'lua', { buf = buf })

vim.bo[buf].buftype = 'nowrite' -- must be last, otherwise LSP will not attach

vim.diagnostic.enable(false, { bufnr = buf })

mappings.set_console_mappings(buf)
Expand Down
8 changes: 5 additions & 3 deletions lua/lua-console/utils.lua
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,7 @@ local function strip_local(lines)
local ts = vim.treesitter
local ret = {}

local start_row = math.max(0, vim.fn.line('.') - 1 - #lines)
local start_row = math.max(-1, vim.fn.line('.') - 1 - #lines)

for i, line in ipairs(lines) do
local cs, ce = 1, 1
Expand All @@ -368,8 +368,10 @@ local function strip_local(lines)
cs, ce = line:find('local%s', ce)

if cs then
local node = ts.get_node { pos = { start_row + i - 1, cs } }
if node and node:parent():type() == 'chunk' then line = line:sub(1, cs - 1) .. line:sub(ce + 1) end
local node = ts.get_node { pos = { start_row + i, cs } }
if node and node:parent() and node:parent():type() == 'chunk' then
line = line:sub(1, cs - 1) .. line:sub(ce + 1)
end
end
end

Expand Down
2 changes: 1 addition & 1 deletion tests/unit/mappings_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ describe('lua-console.nvim - mappings', function()
assert.has_string(vim.fn.bufname(new_buf), 'lua/lua-console.lua')

local line = vim.fn.line('.')
assert.is_same(line, 69)
assert.is_same(line, 70)
end)

it('opens a split with file from stacktrace', function()
Expand Down