From b2c17541da6a3e4c6b5123c8b484fbeb0c8c7021 Mon Sep 17 00:00:00 2001 From: Amar1729 Date: Mon, 6 Nov 2023 23:13:28 -0500 Subject: [PATCH 1/2] fix(docs): use string.find(plain) instead of string.match A `root_dir` might contain special characters `.` or `-` which are not literal in lua patterns. Use the `plain` argument to `string.find` to match a plain string rather than a pattern. https://www.lua.org/manual/5.4/manual.html#pdf-string.find --- README.md | 2 +- doc/portal.nvim.txt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 817eb55..b6cd2b0 100644 --- a/README.md +++ b/README.md @@ -429,7 +429,7 @@ require("portal.builtin").jumplist({ if #root_files > 0 then local root_dir = vim.fs.dirname(root_files[1]) local file_path = vim.api.nvim_buf_get_name(v.buffer) - return string.match(file_path, ("^%s"):format(root_dir)) ~= nil + return string.find(file_path, root_dir, 1, true) ~= nil end return true end diff --git a/doc/portal.nvim.txt b/doc/portal.nvim.txt index 89446fe..82ff0b2 100644 --- a/doc/portal.nvim.txt +++ b/doc/portal.nvim.txt @@ -461,7 +461,7 @@ Examples ~ if root_files > 0 then local root_dir = vim.fs.dirname(root_files[1]) local file_path = vim.api.nvim_buf_get_name(v.buffer) - return string.match(file_path, ("^%s"):format(root_dir)) ~= nil + return string.find(file_path, root_dir, 1, true) ~= nil end return true end From e37f6a276e32b6977e89b29a0fa23a6cb1346b7c Mon Sep 17 00:00:00 2001 From: Calvin Bochulak Date: Sun, 11 Feb 2024 13:16:44 -0700 Subject: [PATCH 2/2] Update doc/portal.nvim.txt --- doc/portal.nvim.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/portal.nvim.txt b/doc/portal.nvim.txt index 82ff0b2..89446fe 100644 --- a/doc/portal.nvim.txt +++ b/doc/portal.nvim.txt @@ -461,7 +461,7 @@ Examples ~ if root_files > 0 then local root_dir = vim.fs.dirname(root_files[1]) local file_path = vim.api.nvim_buf_get_name(v.buffer) - return string.find(file_path, root_dir, 1, true) ~= nil + return string.match(file_path, ("^%s"):format(root_dir)) ~= nil end return true end