Skip to content

Commit

Permalink
fix for method documentation search (#233)
Browse files Browse the repository at this point in the history
* fix doc search for methods on lines starting with class name and respect windows path separators

* replace Windows check with built-in function

* PR changes

* fix incorrect on_open method call
  • Loading branch information
sadguitarius authored Apr 19, 2024
1 parent 8929739 commit 94e49fa
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions lua/scnvim/help.lua
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ M.on_open = action.new(function(err, uri, pattern)
local is_open = vim.fn.win_gotoid(win_id) == 1
local expr = string.format('edit %s', uri)
if pattern then
expr = string.format('edit +/%s %s', pattern, uri)
local subject = vim.fn.fnamemodify(uri, ':t:r')
expr = string.format('edit +/^\\\\(%s\\\\)\\\\?%s %s', subject, pattern, uri)
end
if is_open then
vim.cmd(expr)
Expand Down Expand Up @@ -112,14 +113,12 @@ local function open_from_quickfix(index)
local item = list[index]
if item then
local uri = vim.fn.bufname(item.bufnr)
local subject = vim.fn.fnamemodify(uri, ':t:r')
if uv.fs_stat(uri) then
M.on_open(nil, uri, item.pattern)
M.on_open(nil, uri, item.text)
else
local cmd = string.format('SCNvim.getFileNameFromUri("%s")', uri)
sclang.eval(cmd, function(subject)
render_help_file(subject, function(result)
M.on_open(nil, result, item.pattern)
end)
render_help_file(subject, function(result)
M.on_open(nil, result, item.text)
end)
end
end
Expand Down Expand Up @@ -169,7 +168,6 @@ local function find_methods(name, target_dir)
table.insert(results, {
filename = destpath,
text = string.format('.%s', name),
pattern = string.format('^\\.%s', name),
})
end
end
Expand Down

0 comments on commit 94e49fa

Please sign in to comment.