fix diagnostics showing up on file/dir with same prefix#1832
fix diagnostics showing up on file/dir with same prefix#1832alex-courtis merged 4 commits intomasterfrom
Conversation
|
Hmmmmm now that I look at it |
|
Unfortunately I am out of time; I'll get to this one on the weekend. |
startswith is very useful. I should use that more. It looks like we do need |
|
Looks like startswith is a winner: it doesn't match any vim or lua patterns. Much simpler than string.find plain. local needle = "/cc"
local haystack = "/cc/dd/ee"
log.line("dev", "needle '%s' haystack '%s' startswith %s", needle, haystack, vim.startswith(haystack, needle))
log.line("dev", "needle '%s' haystack '%s' vim.fn.match %s", needle, haystack, vim.fn.match(haystack, needle))
log.line("dev", "needle '%s' haystack '%s' string.match %s", needle, haystack, string.match(haystack, needle))
log.line("dev", "needle '%s' haystack '%s' string.find %s", needle, haystack, string.find(haystack, needle))
log.line("dev", "needle '%s' haystack '%s' string.find %s", needle, haystack, string.find(haystack, needle, 1, true))
log.line("dev", "")
needle = "c:\\cc"
haystack = "c:\\cc\\dd\\ee"
log.line("dev", "needle '%s' haystack '%s' startswith %s", needle, haystack, vim.startswith(haystack, needle))
log.line("dev", "needle '%s' haystack '%s' vim.fn.match %s", needle, haystack, vim.fn.match(haystack, needle))
log.line("dev", "needle '%s' haystack '%s' string.match %s", needle, haystack, string.match(haystack, needle))
log.line("dev", "needle '%s' haystack '%s' string.find %s", needle, haystack, string.find(haystack, needle))
log.line("dev", "needle '%s' haystack '%s' string.find %s", needle, haystack, string.find(haystack, needle, 1, true))
log.line("dev", "")
needle = "c:\\.c"
haystack = "c:\\cc\\dd\\ee"
log.line("dev", "needle '%s' haystack '%s' startswith %s", needle, haystack, vim.startswith(haystack, needle))
log.line("dev", "needle '%s' haystack '%s' vim.fn.match %s", needle, haystack, vim.fn.match(haystack, needle))
log.line("dev", "needle '%s' haystack '%s' string.match %s", needle, haystack, string.match(haystack, needle))
log.line("dev", "needle '%s' haystack '%s' string.find %s", needle, haystack, string.find(haystack, needle))
log.line("dev", "needle '%s' haystack '%s' string.find %s", needle, haystack, string.find(haystack, needle, 1, true))
log.line("dev", "")
needle = "c:\\%ac"
haystack = "c:\\cc\\dd\\ee"
log.line("dev", "needle '%s' haystack '%s' startswith %s", needle, haystack, vim.startswith(haystack, needle))
-- log.line("dev", "needle '%s' haystack '%s' vim.fn.match %s", needle, haystack, vim.fn.match(haystack, needle))
log.line("dev", "needle '%s' haystack '%s' string.match %s", needle, haystack, string.match(haystack, needle))
log.line("dev", "needle '%s' haystack '%s' string.find %s", needle, haystack, string.find(haystack, needle))
log.line("dev", "needle '%s' haystack '%s' string.find %s", needle, haystack, string.find(haystack, needle, 1, true)) |
The key part is the gsub works even for crazy paths like |
alex-courtis
left a comment
There was a problem hiding this comment.
Tested OK:
nvim-tree.lua/lua show_on_dirs show_on_open_dirs
- false false
- true false
- false true
- true true
nvim-tree/lua\lua
as above
If A's path is B's prefix, then diagnostics in B will show up in both of them. For example, if there's diagnostics for
lua/nvim-tree.lua,lua/nvim-tree/will also show diagnostics even though non of it's children have any.This PR fixes that.