Skip to content

Commit

Permalink
Display luaurc aliases in original case in require autocompletion
Browse files Browse the repository at this point in the history
  • Loading branch information
JohnnyMorganz committed Dec 14, 2024
1 parent 891698f commit 2cc27f3
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).

- Fixed `luau-lsp analyze --settings=...` crashing when a malformed settings JSON file is provided. Now, it will print the json error and continue assuming the settings did not exist
- Fixed regression in require by string autocompletion failing to correctly autocomplete files under directories ([#851](https://github.com/JohnnyMorganz/luau-lsp/issues/851))
- Autocompletion in string requires will now show aliases in their original case defined in `.luaurc`, rather than all lowercased

## [1.36.0] - 2024-11-30

Expand Down
4 changes: 2 additions & 2 deletions src/platform/LSPPlatform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -209,12 +209,12 @@ std::optional<Luau::AutocompleteEntryMap> LSPPlatform::completionCallback(
// Populate with custom aliases, if we are at the start of a string require
if (contentsString.empty())
{
for (const auto& [aliasName, _] : luauConfig.aliases)
for (const auto& [_, aliasInfo] : luauConfig.aliases)
{
Luau::AutocompleteEntry entry{Luau::AutocompleteEntryKind::String, workspaceFolder->frontend.builtinTypes->stringType, false, false,
Luau::TypeCorrectKind::Correct};
entry.tags.push_back("Alias");
result.insert_or_assign("@" + aliasName, entry);
result.insert_or_assign("@" + aliasInfo.originalCase, entry);
}
// DEPRECATED
for (const auto& [aliasName, _] : config.require.fileAliases)
Expand Down
4 changes: 2 additions & 2 deletions tests/Autocomplete.test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -833,8 +833,8 @@ TEST_CASE_FIXTURE(Fixture, "string_require_contains_luaurc_aliases")
CHECK_EQ(result.size(), 4);
checkFolderCompletionExists(result, "..");
checkFileCompletionExists(result, "source.luau");
requireItem(result, "@roact");
requireItem(result, "@fusion");
requireItem(result, "@Roact");
requireItem(result, "@Fusion");
}

TEST_CASE_FIXTURE(Fixture, "string_require_contains_file_aliases")
Expand Down

0 comments on commit 2cc27f3

Please sign in to comment.