Skip to content

Commit

Permalink
Fix regression in DataModel autocompletion and friends
Browse files Browse the repository at this point in the history
Fixes #345
  • Loading branch information
JohnnyMorganz committed Apr 27, 2023
1 parent 8010ce7 commit 4a07c56
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).

## [Unreleased]

### Fixed

- Fixed regression in DataModel item autocompletion

## [1.19.0] - 2023-04-26

### Deprecated
Expand Down
13 changes: 7 additions & 6 deletions src/LuauExt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -481,8 +481,11 @@ void registerInstanceTypes(Luau::Frontend& frontend, const Luau::GlobalTypes& gl
}

// Prepare module scope so that we can dynamically reassign the type of "script" to retrieve instance info
frontend.prepareModuleScope = [&, expressiveTypes](const Luau::ModuleName& name, const Luau::ScopePtr& scope, bool forAutocomplete)
frontend.prepareModuleScope = [&frontend, &fileResolver, &arena, expressiveTypes](
const Luau::ModuleName& name, const Luau::ScopePtr& scope, bool forAutocomplete)
{
Luau::GlobalTypes& globals = forAutocomplete ? frontend.globalsForAutocomplete : frontend.globals;

// TODO: we hope to remove these in future!
if (!expressiveTypes && !forAutocomplete)
{
Expand All @@ -491,12 +494,10 @@ void registerInstanceTypes(Luau::Frontend& frontend, const Luau::GlobalTypes& gl
scope->bindings[Luau::AstName("game")] = Luau::Binding{globals.builtinTypes->anyType};
}

if (auto node =
fileResolver.isVirtualPath(name) ? fileResolver.getSourceNodeFromVirtualPath(name) : fileResolver.getSourceNodeFromRealPath(name))
{
if (expressiveTypes)
if (expressiveTypes)
if (auto node =
fileResolver.isVirtualPath(name) ? fileResolver.getSourceNodeFromVirtualPath(name) : fileResolver.getSourceNodeFromRealPath(name))
scope->bindings[Luau::AstName("script")] = Luau::Binding{getSourcemapType(globals, arena, node.value())};
}
};
}

Expand Down
2 changes: 2 additions & 0 deletions src/Workspace.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,8 @@ bool WorkspaceFolder::updateSourceMap()
instanceTypes.clear();
types::registerInstanceTypes(frontend, frontend.globals, instanceTypes, fileResolver,
/* expressiveTypes: */ config.diagnostics.strictDatamodelTypes);
types::registerInstanceTypes(frontend, frontend.globalsForAutocomplete, instanceTypes, fileResolver,
/* expressiveTypes: */ true);

return true;
}
Expand Down

0 comments on commit 4a07c56

Please sign in to comment.