Skip to content

Conversation

@ordinary-slim
Copy link
Contributor

@ordinary-slim ordinary-slim commented Nov 2, 2025

Addresses #3224 . Tests (ran with make in tests folder) run.

@ordinary-slim ordinary-slim changed the title dont mkdir all paths that start with '..' (instead of '../' previously) dont mkdir any path that start with '..' (instead of '../' previously) Nov 2, 2025
@ordinary-slim ordinary-slim changed the title dont mkdir any path that start with '..' (instead of '../' previously) dont mkdir any path that starts with '..' (instead of '../' previously) Nov 2, 2025
@lervag
Copy link
Owner

lervag commented Nov 5, 2025

Thanks, I appreciate the proposed fix. I'll probably accept it, but please consider my questions/comments in #3224 first.

@lervag
Copy link
Owner

lervag commented Nov 8, 2025

Cool, as I can now reproduce this, I also understand it better. So, I don't think we should change the regex here. Instead, we should apply a simplify() on the dirs before we do the filter. That is, the following diff against your PR should be a more robust fix:

diff --git a/autoload/vimtex/compiler/_template.vim b/autoload/vimtex/compiler/_template.vim
index 7ec64c3b..28b5022c 100644
--- a/autoload/vimtex/compiler/_template.vim
+++ b/autoload/vimtex/compiler/_template.vim
@@ -125,7 +125,7 @@ function! s:compiler._create_build_dir(path) abort dict " {{{1
     call filter(map(
           \ l:dirs, "fnamemodify(v:val, ':h')"),
           \ {_, x -> x !=# '.'})
-    call filter(l:dirs, {_, x -> stridx(x, '..') != 0})
+    call filter(l:dirs, {_, x -> stridx(x, '../') != 0})
   else
     let l:dirs = glob(self.file_info.root . '/**/*.tex', v:false, v:true)
     call map(l:dirs, "fnamemodify(v:val, ':h')")
@@ -136,6 +136,7 @@ function! s:compiler._create_build_dir(path) abort dict " {{{1
   call map(l:dirs, {_, x ->
         \ (vimtex#paths#is_abs(a:path) ? '' : self.file_info.root . '/')
         \ . a:path . '/' . x})
+  call map(l:dirs, {_, x -> simplify(x) })
   call filter(l:dirs, '!isdirectory(v:val)')
   if empty(l:dirs) | return | endif

Fixes bug where 'mkdir('./build/..') is called
@ordinary-slim
Copy link
Contributor Author

Your solution is more robust, thanks for letting me commit it.

@lervag lervag merged commit bef1025 into lervag:master Nov 9, 2025
1 check passed
@lervag
Copy link
Owner

lervag commented Nov 9, 2025

No problem, and thanks again for your contribution! I'm always happy when people (like you) both detect a problem and attempt to fix it themselves, and I'm glad to assist and let you complete the final stages. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants