runtime(netrw): Fixing global variable initialization on Windows#19287
runtime(netrw): Fixing global variable initialization on Windows#19287MiguelBarro wants to merge 3 commits intovim:masterfrom
Conversation
Signed-off-by: Guybrush <miguel.barro@live.com>
Signed-off-by: Guybrush <miguel.barro@live.com>
613e656 to
c258a4b
Compare
|
Thanks. I am a bit unsure, whether or not to consider this for the Vim 9.2 release. I'll probably move it to after the release, as this is currently too much to review with confidence |
There was a problem hiding this comment.
Pull request overview
This PR fixes global variable initialization issues in the netrw plugin on Windows. The core problem was that default option variables were initialized as empty strings early in the script, preventing platform-specific values from being set later. The PR restructures initialization to properly detect the platform and set appropriate commands for Windows (using cmd.exe with COMSPEC) versus Unix systems. Additionally, it fixes shellslash handling throughout file operations and significantly expands test coverage for file management functions across different shells (default, PowerShell, and pwsh).
Changes:
- Restructured initialization of netrw global variables to properly set Windows-specific commands
- Fixed shellslash option handling in path composition and file operations
- Added comprehensive test infrastructure and coverage for file operations (mkdir, copy, move) across multiple shells
Reviewed changes
Copilot reviewed 1 out of 3 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| src/testdir/test_plugin_netrw.vim | Extensively refactored test infrastructure with new test helpers, added SetUp/TearDown functions, and comprehensive tests for file operations across different shells |
| runtime/pack/dist/opt/netrw/autoload/netrw/fs.vim | Fixed ComposePath to respect shellslash option when choosing path separator |
| runtime/pack/dist/opt/netrw/autoload/netrw.vim | Restructured global variable initialization, updated file copy/move operations to handle Windows properly and respect shellslash, simplified error handling |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Signed-off-by: Guybrush <miguel.barro@live.com>
5360148 to
2372b9a
Compare
Some default options are initialized as empty:
vim/runtime/pack/dist/opt/netrw/autoload/netrw.vim
Lines 69 to 73 in 3715836
preventing them later from getting the rigth value:
vim/runtime/pack/dist/opt/netrw/autoload/netrw.vim
Lines 295 to 301 in 3715836
because
s:NetrwInit()will only set values for undefined variables:vim/runtime/pack/dist/opt/netrw/autoload/netrw.vim
Lines 53 to 57 in 3715836
After the fix, things were not working so I revamp those functions where the default options were used. Besides:
shellslashoption.netrwtesting accordingly.