Visitar URL original
Fix Windows autocmd to only intercept /tmp/ paths · python-mode/python-mode@85fe55b · GitHub
Skip to content

Commit 85fe55b

Browse files
committed
Fix Windows autocmd to only intercept /tmp/ paths
The previous autocmd pattern '*' was intercepting ALL writes, causing issues with normal file operations. Changed to only intercept /tmp/*: - BufWriteCmd /tmp/* - catches :write! /tmp/file - FileWriteCmd /tmp/* - catches direct file writes to /tmp/ - Removed else branch that was calling noautocmd write for all files - This prevents interference with normal Vim write operations Fixes Windows CI by only handling the specific /tmp/ path issue.
1 parent 2f93ef8 commit 85fe55b

1 file changed

Lines changed: 16 additions & 23 deletions

File tree

‎scripts/cicd/run_vader_tests_windows.ps1‎

Lines changed: 16 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -159,32 +159,25 @@ if has('win32') || has('win64')
159159
endif
160160
return a:path
161161
endfunction
162-
" Intercept all file writes and redirect /tmp/ paths
163-
function! s:HandleFileWrite()
162+
" Intercept only /tmp/ path writes
163+
function! s:HandleTmpWrite()
164164
let l:filename = expand('<afile>:p')
165-
" Check if this is a /tmp/ path
166-
if l:filename =~# '^/tmp/'
167-
let l:converted = s:ConvertTmpPath(l:filename)
168-
" Create directory if needed
169-
let l:win_dir = fnamemodify(l:converted, ':h')
170-
if !isdirectory(l:win_dir)
171-
call mkdir(l:win_dir, 'p')
172-
endif
173-
" Write to converted path using noautocmd to avoid recursion
174-
noautocmd execute 'write! ' . fnameescape(l:converted)
175-
" Update buffer name
176-
noautocmd execute 'file ' . fnameescape(l:converted)
177-
else
178-
" Not a /tmp/ path, do normal write
179-
" Use noautocmd to avoid recursion, then call normal write
180-
noautocmd write
165+
let l:converted = s:ConvertTmpPath(l:filename)
166+
" Create directory if needed
167+
let l:win_dir = fnamemodify(l:converted, ':h')
168+
if !isdirectory(l:win_dir)
169+
call mkdir(l:win_dir, 'p')
181170
endif
171+
" Write to converted path using noautocmd to avoid recursion
172+
noautocmd execute 'write! ' . fnameescape(l:converted)
173+
" Update buffer name
174+
noautocmd execute 'file ' . fnameescape(l:converted)
182175
endfunction
183-
" Use BufWriteCmd to catch all buffer writes (including :write! /path)
184-
" This fires before the actual write happens and replaces normal write
185-
autocmd BufWriteCmd * call s:HandleFileWrite()
186-
" Also catch FileWriteCmd for direct file writes
187-
autocmd FileWriteCmd * call s:HandleFileWrite()
176+
" ONLY intercept writes to /tmp/ paths - don't interfere with other writes
177+
" Use BufWriteCmd to catch :write! /tmp/file
178+
autocmd BufWriteCmd /tmp/* call s:HandleTmpWrite()
179+
" Use FileWriteCmd to catch direct file writes to /tmp/
180+
autocmd FileWriteCmd /tmp/* call s:HandleTmpWrite()
188181
endif
189182
190183
" Enable magic for motion support (required for text object mappings)

0 commit comments

Comments
 (0)