Autocomplete selects the wrong option when typing

Reproduction Steps

  1. Insert a new script, paste the following code:
function doTest(part)
	part.Name = "hi"
	
	print(part.n)
end

local newPart = Instance.new("Part")

doTest(newPart)
  1. Complete typing on part.n. While typing, Studio will select the autocomplete option of what I’m typing

Expected Behavior
Studio should select the next-best autocomplete option there is available

Actual Behavior
Studio selects the autocomplete option that is 1:1 to what I’m typing. It’s not useful if you have to use arrow keys/mouse selection to get your result instead.

Issue Area: Studio
Issue Type: Display
Impact: High
Frequency: Constantly

9 Likes

The trouble here is that, since we have no type for “part,” we need to infer one. Based on the contents of the script when we generate the Autocomplete suggestions, the type inference believes that part is a table type with properties ‘Name’ and whatever you’ve typed on line 4. We’ll take a look to see if we can improve this case.

As a workaround, you should be able to avoid this by specifying a type for part. For example try changing function doTest(part) -> function doTest(part : BasePart)

6 Likes

Yes, I declared the property in the line above it though. Using types isn’t really a solution for us; as we have existing codebases not written to support them. Having autocomplete always suggesting the exact phrase I am typing out isn’t helpful to me, I would rather it deprioritizes that first option and tries to suggest any other complete results.

This isn’t an issue in Sublime text:

4 Likes

You still didn’t declare the type.
function doTest(part : BasePart) is the correct way to declare it.
This isn’t a bug. Roblox Studio intentionally doesn’t assume the type without a type declaration. In the newer update, Roblox will auto-complete with type declarations.

1 Like

Sublime Text doesn’t have Luau analysis. I think the point they’re trying to make is that Studio should not count the string you are autocompleting as one of the autocomplete options if there are no other instances of it in your code.

2 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.