Closed emmanueltouzery closed 1 year ago
so I looked at this a little more...
local splited_path = vim.split(selection.value.path, ",")
-- ...
operations.open(selection.value.alias, bufnr, splited_path[2], float)
the next-to-last parameter for open() is the pattern to search for when displaying the documentation:
M.open = function(alias, bufnr, pattern, float)
In the case of lodash .at, which works, selection.value.path is `1,### .at(object, [paths])source npm package. And
splitedpath[2]is:
### .at(object`.
In the case of lodash.keys, which doesn't work, selection.value.path is 1,### _.keys(object)[source](https://github.com/lodash/lodash/blob/4.17.10/lodash.js#L13305) [npm package](https://www.npmjs.com/package/lodash.keys)
.
And splited_path[2]
is: ### _.keys(object)[source](https://github.com/lodash/lodash/blob/4.17.10/lodash.js#L13305) [npm package](https://www.npmjs.com/package/lodash.keys)
.
My interpretation is that the search pattern is the markdown. But when rendering through glow search for the markdown pattern won't work, since glow will format values differently. That's why ideally I'd consider splitting the markdown and then feeding to glow (or any other renderer) the relevant part of the markdown, because who knows how the renderer will reformat the markdown.
In any case, from my understanding, in the case of _.at
it works by luck, because you split on ,
, and the function has multiple parameters, which are separated by ,
and so you search on only a little subset of the line, which happens to match. In the case of _.keys
there is only a single parameter, and so you search on the whole markdown line (as intended), however it doesn't work because glow reformatted the markdown differently.
That's my understanding anyway. As I said, as for myself I'd consider splitting the markdown and then feeding to glow only the part that's relevant to it. That would solve multiple issues: glow's slowness (although it's better with the latest unreleased glow, but it's still >1s which is noticeable), the preview in telescope (no need to scroll since glow would output only the relevant part) and also this issue.
Thank you for all your remarks! I didn't expect that links could be used in the headers, and splitting with the headers sounds like the optimal way. It will require more work, but it should be possible. I should have considered this approach from the start... Also, I'm quite busy at the moment, but I'll try to get that soon.
By the way, I enabled discussions for the repo (I should also have done that from the start)
so i disabled the telescope preview for now since the jumping to section doesn't work for that, and things are much better, but I noticed that jumping to the correct section, while it works for instance for lodash-4
_.at
, or_.gt
for instance, doesn't work for_.keys
. I have no idea why.Note that I use the glow integration (with latest git glow for performance).