Skip to content

Commit

Permalink
fix(util): normalize path in util.doc_is_open
Browse files Browse the repository at this point in the history
  • Loading branch information
Guldoman committed Jun 1, 2024
1 parent ed83454 commit 21faf00
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions util.lua
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,12 @@ local util = {}
---Check if the given file is currently opened on the editor.
---@param abs_filename string
function util.doc_is_open(abs_filename)
-- make path separator consistent
abs_filename = abs_filename:gsub("\\", "/")
-- Normalize path format to the one used by normal docs
abs_filename = common.normalize_path(abs_filename) or abs_filename
for _, doc in ipairs(core.docs) do
---@cast doc core.doc
if doc.abs_filename then
local doc_path = doc.abs_filename:gsub("\\", "/")
if doc_path == abs_filename then
return true;
end
if doc.abs_filename == abs_filename then
return true;
end
end
return false
Expand Down

0 comments on commit 21faf00

Please sign in to comment.