mirror of
				https://github.com/neovim/neovim.git
				synced 2025-10-26 12:27:24 +00:00 
			
		
		
		
	fix(fs.lua): normalize slash truncation
Preserve last slash in windows' root drive directories
(cherry picked from commit 886996ff74)
			
			
This commit is contained in:
		 Mike
					Mike
				
			
				
					committed by
					
						![github-actions[bot]](/assets/img/avatar_default.png) github-actions[bot]
						github-actions[bot]
					
				
			
			
				
	
			
			
			![github-actions[bot]](/assets/img/avatar_default.png) github-actions[bot]
						github-actions[bot]
					
				
			
						parent
						
							b0abe426d6
						
					
				
				
					commit
					c0c6294123
				
			| @@ -344,7 +344,11 @@ function M.normalize(path, opts) | |||||||
|     path = path:gsub('%$([%w_]+)', vim.loop.os_getenv) |     path = path:gsub('%$([%w_]+)', vim.loop.os_getenv) | ||||||
|   end |   end | ||||||
|  |  | ||||||
|   return (path:gsub('\\', '/'):gsub('/+', '/'):gsub('(.)/$', '%1')) |   path = path:gsub('\\', '/'):gsub('/+', '/') | ||||||
|  |   if iswin and path:match('^%w:/$') then | ||||||
|  |     return path | ||||||
|  |   end | ||||||
|  |   return (path:gsub('(.)/$', '%1')) | ||||||
| end | end | ||||||
|  |  | ||||||
| return M | return M | ||||||
|   | |||||||
| @@ -290,5 +290,10 @@ describe('vim.fs', function() | |||||||
|         return vim.fs.normalize('$XDG_CONFIG_HOME/nvim') |         return vim.fs.normalize('$XDG_CONFIG_HOME/nvim') | ||||||
|       ]], xdg_config_home)) |       ]], xdg_config_home)) | ||||||
|     end) |     end) | ||||||
|  |     if is_os('win') then | ||||||
|  |       it('Last slash is not truncated from root drive', function() | ||||||
|  |         eq('C:/', exec_lua [[ return vim.fs.normalize('C:/') ]]) | ||||||
|  |       end) | ||||||
|  |     end | ||||||
|   end) |   end) | ||||||
| end) | end) | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user