Script editor incorrectly auto-indents some if statements


#1

While editing scripts in Roblox Studio’s Script editor: pressing enter on the line of an END statement can incorrectly auto-indent that line, and the line that follows it.

See what happens when I try to create a new line by hitting enter at line 29:

Image from Gyazo

Here is the exact code. This bug is reproduced 100% by the IF statement on line 29, as shown in the gif above. Just copy/paste this code into script editor and try to start a new line after the END statement that closes module.partyRequest

local module = {}

local activePlayer


function module.init(Modules)
	local tween = Modules.tween
	local network = Modules.network
	
	function module.open(player)
		activePlayer = player

		script.Parent.UIScale.Scale = 0.75
		Modules.tween(script.Parent.UIScale, {"Scale"}, 1, 0.5, Enum.EasingStyle.Bounce)	
		Modules.focus.toggle(script.Parent)
	end	

	function module.partyRequest()
		if activePlayer and script.Parent.options.Visible then
			local target = activePlayer
			local success, reason 
				success, reason = network:invokeServer("playerRequest_invitePlayerToMyParty", target)
			if success then
				Modules.notifications.alert({text = "Invited "..target.Name.." to the party."}, 2)
			elseif reason then
				Modules.notifications.alert({text = reason or "Error occured"}, 2)
			end	
		end	
	end

		
end

	

return module



This issue happens 100% of the time. It has been happening for over half a year and it is seriously driving me insane.


#2

This has been driving me insane lately. +1


#3

Is this the same issue?

The example in the first post has it on end) but example gifs later in the thread show it also happening to plain ends.


#4

Not exactly the same issue. In the linked post, it auto-indents the end statement but then the next line starts with the correct indentation.

With the above code, it auto-indents and starts the next line on the wrong indentation.


#5

I swear to god this bug actually drives me insane – I always have to go back and correct it. Please for the love of god get this fixed. :pray:


#6

This happens to me as well.


#7

This is quite an annoying bug, as someone who really wants their code to look clean and readable I have to spend extra effort reorganizing code when the indentation messes up. It interrupts workflow quite a bit.


#8

This happens to me quite often as well.


#9

Yeah, I can reproduce this and I like to keep my code clean and nice just in case I add someone to help me and don’t confuse them.


#10

Happens for me as well. But I get the “opposite” issue where ends indent to the left after closing a table and pressing enter. Here’s a sniplet of the code in question.

The issue happens at the very end, so if you try placing this into a function or just a “do end” statement, you should be able to replicate this easily.

local ud = newproxy(true) local mt = getmetatable(ud)
do
    local f={}
    local ntf = {}
	mt.__index={
		Fire=function(...)
			for i=1,#f do
				if f[i] then f[i](...) end
			end
		end,
		Connect=function(n,func)
			local i=1
			while f[i]do
				i=i+1
			end
			f[i],ntf[n]=func,i
		end,
		Disconnect=function(n)
			f[ntf[n]]=nil ntf[n]=nil
		end
	}
end