mirror of
				https://github.com/neovim/neovim.git
				synced 2025-11-04 01:34:25 +00:00 
			
		
		
		
	fix(vim.opt): vimL map string values not trimmed (#14982)
Options formatted as a list of comma-separated key-value pairs may have values that contain leading and trailing whitespace characters. For example, the `listchars` option has a default value of `"tab:> ,trail:-,nbsp:+"`. When converting this value to a lua table, leading and trailing whitespace should not be trimmed. Co-authored-by: Robert Hrusecky <robert.hrusecky@utexas.edu>
This commit is contained in:
		@@ -494,7 +494,6 @@ local convert_value_to_lua = (function()
 | 
				
			|||||||
      for _, key_value_str in ipairs(comma_split) do
 | 
					      for _, key_value_str in ipairs(comma_split) do
 | 
				
			||||||
        local key, value = unpack(vim.split(key_value_str, ":"))
 | 
					        local key, value = unpack(vim.split(key_value_str, ":"))
 | 
				
			||||||
        key = vim.trim(key)
 | 
					        key = vim.trim(key)
 | 
				
			||||||
        value = vim.trim(value)
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
        result[key] = value
 | 
					        result[key] = value
 | 
				
			||||||
      end
 | 
					      end
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1332,12 +1332,12 @@ describe('lua stdlib', function()
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
      it('should work for key-value pair options', function()
 | 
					      it('should work for key-value pair options', function()
 | 
				
			||||||
        local listchars = exec_lua [[
 | 
					        local listchars = exec_lua [[
 | 
				
			||||||
          vim.opt.listchars = "tab:>~,space:_"
 | 
					          vim.opt.listchars = "tab:> ,space:_"
 | 
				
			||||||
          return vim.opt.listchars:get()
 | 
					          return vim.opt.listchars:get()
 | 
				
			||||||
        ]]
 | 
					        ]]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        eq({
 | 
					        eq({
 | 
				
			||||||
          tab = ">~",
 | 
					          tab = "> ",
 | 
				
			||||||
          space = "_",
 | 
					          space = "_",
 | 
				
			||||||
        }, listchars)
 | 
					        }, listchars)
 | 
				
			||||||
      end)
 | 
					      end)
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user