cdelledonne / vim-cmake

Vim/Neovim plugin for working with CMake projects
MIT License
259 stars 21 forks source link

Too many backslash character on directory that contains space #78

Closed mrizaln closed 1 year ago

mrizaln commented 1 year ago

Bug description

The cmake command string that generated when calling :CMakeGenerate and :CMakeBuild has too many backslash character on directory with space character.

project directory

$ pwd
/tmp/directory with space/project

:CMakeGenerate output

Running command: cmake -D CMAKE_BUILD_TYPE=Debug -D CMAKE_EXPORT_COMPILE_COMMANDS=ON -S /tmp/directory\\\ with\\\ space/project -B /tmp/directory\\\\\\\\\\\\\\\ with\\\\\\\\\\\\\\\ space    
/project/Debug

:CMakeBuild output

Running command: cmake --build /tmp/directory\\\\\\\\\\\\\\\ with\\\\\\\\\\\\\\\ space/project/Debug

To Reproduce

Steps to reproduce the behavior:

  1. Create a new project directory inside a directory that contains space.
  2. Create some C file.
  3. Create CMakeLists.txt file for that C file.
  4. Open neovim.
  5. Run :CMakeGenerate and :CMakeBuild.

Expected behavior

Exactly one backslash character per space character.

Behavior with minimal .vimrc

The same as above.

minimal .vimrc

call plug#begin('~/.config/nvim/plugged')
Plug 'cdelledonne/vim-cmake'
call plug#end()

let g:cmake_link_compile_commands=1
nmap <leader>cg :CMakeGenerate<cr>
nmap <leader>cb :CMakeBuild<cr>

Screenshots

image

Other info

Additional context

log

[2022-12-21 15:43:50] [ INFO] Configuration options:
[2022-12-21 15:43:50] [ INFO] > g:cmake_build_dir_location: '.'
[2022-12-21 15:43:50] [ INFO] > g:cmake_build_options: []
[2022-12-21 15:43:50] [ INFO] > g:cmake_command: 'cmake'
[2022-12-21 15:43:50] [ INFO] > g:cmake_console_echo_cmd: 1
[2022-12-21 15:43:50] [ INFO] > g:cmake_console_position: 'botright'
[2022-12-21 15:43:50] [ INFO] > g:cmake_console_size: 15
[2022-12-21 15:43:50] [ INFO] > g:cmake_default_config: 'Debug'
[2022-12-21 15:43:50] [ INFO] > g:cmake_generate_options: []
[2022-12-21 15:43:50] [ INFO] > g:cmake_jump: 0
[2022-12-21 15:43:50] [ INFO] > g:cmake_jump_on_completion: 0
[2022-12-21 15:43:50] [ INFO] > g:cmake_jump_on_error: 1
[2022-12-21 15:43:50] [ INFO] > g:cmake_link_compile_commands: 1
[2022-12-21 15:43:50] [ INFO] > g:cmake_log_file: 'VIM_CMAKE_LOG'
[2022-12-21 15:43:50] [ INFO] > g:cmake_log_level: 'INFO'
[2022-12-21 15:43:50] [ INFO] > g:cmake_native_build_options: []
[2022-12-21 15:43:50] [ INFO] > g:cmake_reinit_on_dir_changed: 1
[2022-12-21 15:43:50] [ INFO] > g:cmake_restore_state: 1
[2022-12-21 15:43:50] [ INFO] > g:cmake_root_markers: ['.git', '.svn']
[2022-12-21 15:43:50] [ INFO] > g:cmake_statusline: 0
[2022-12-21 15:43:50] [ INFO] > g:cmake_test_command: 'ctest'
[2022-12-21 15:43:50] [ INFO] > g:cmake_test_options: []
[2022-12-21 15:43:50] [ INFO] Project root: /tmp/directory\ with\ space/project
[2022-12-21 15:43:50] [ INFO] Current config: Debug (/tmp/directory\\\\\\\ with\\\\\\\ space/project/Debug)
cdelledonne commented 1 year ago

Hi, thanks a lot for reporting this, and apologies for the huge delay.

I can indeed reproduce the issue. It seems that escaping paths with spaces multiple times leads to this problem. A solution that seems to work is to skip path escaping altogether, since that shouldn't be really necessary in what we need paths for.

Can you please try branch 78-do-not-escape-paths and see if the issue is resolved? I will so some testing in Vim and on Windows as well, and if the issue is actually gone I'll merge the changes asap.

mrizaln commented 1 year ago

Hi, thanks for your hard work!

I have tried branch 78-do-not-escape-paths on my machine. The issue is indeed resolved.

cdelledonne commented 1 year ago

Great, I just merged the fix on the master branch