vim-lua icon indicating copy to clipboard operation
vim-lua copied to clipboard

Outdent line after an anon func argument

Open idbrii opened this issue 3 years ago • 1 comments

Fix anonymous function argument causes following line to be incorrectly indented.

Previously, it would give indentation like this:

data = self.kitchen
	:digestCheese(function()
		return 1
	end)
	self:Func() -- wrong indentation

data = self.kitchen
	:eatCheese({fn = function()
		return 10
	end})
		:digestCheese() -- wrong indentation

Now, it's like this:

data = self.kitchen
	:digestCheese(function()
		return 1
	end)
self:Func()

data = self.kitchen
	:eatCheese({fn = function()
		return 10
	end})
	:digestCheese()

Add vader.vim tests:

  • indented chained functions:
    • worked before and still works
  • indented chained anonymous function arguments:
    • broken before and now works
  • indented non first argument anonymous function:
    • broken before and now works

idbrii avatar Jan 15 '22 06:01 idbrii

Convert to draft: This causes incorrect indentation after an anonymous function in some cases.

if level then
   local room = self:find(function(r)
      return r.name == level
   end)
if room then -- here
   print(room)
end
end

local p = self.input:getActiveControls(function(value)
   local name_remap = {
   }
   return name_remap[value] or value
end)
   print(p) -- here

idbrii avatar Mar 09 '22 16:03 idbrii