Skip to content
Open
Show file tree
Hide file tree
Changes from 4 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
4 changes: 3 additions & 1 deletion lua/trouble/item.lua
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ local Util = require("trouble.util")
---@field source string
---@field cache table<string,any>
---@field range? trouble.Range
---@field cwd? string
local M = {}

---@param opts trouble.Item | {filename?:string}
Expand All @@ -36,7 +37,8 @@ function M.new(opts)
end
assert(self.filename, "filename is required")
if self.filename then
self.filename = vim.fs.normalize(self.filename)
local path = self.cwd and vim.fs.joinpath(self.cwd, self.filename) or self.filename
self.filename = vim.fs.normalize(path)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should not be needed?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are right, I handled the normalization wrong 🤦
I'll normalize the filename first, and also the cwd

local parts = vim.split(self.filename, "/", { plain = true })
self.basename = table.remove(parts)
self.dirname = table.concat(parts, "/")
Expand Down
1 change: 1 addition & 0 deletions lua/trouble/sources/snacks.lua
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ function M.item(item)
return Item.new({
source = "snacks",
buf = item.buf,
cwd = item.cwd,
filename = item.file,
pos = item.pos,
end_pos = item.end_pos,
Expand Down