From 2cc27f37e73813f0cbf5cd4e00191a8103a2633f Mon Sep 17 00:00:00 2001 From: JohnnyMorganz Date: Sat, 14 Dec 2024 11:18:26 +0000 Subject: [PATCH] Display luaurc aliases in original case in require autocompletion --- CHANGELOG.md | 1 + src/platform/LSPPlatform.cpp | 4 ++-- tests/Autocomplete.test.cpp | 4 ++-- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ff1992f7..16c0dcb1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/src/platform/LSPPlatform.cpp b/src/platform/LSPPlatform.cpp index 929edc81..b7c9faec 100644 --- a/src/platform/LSPPlatform.cpp +++ b/src/platform/LSPPlatform.cpp @@ -209,12 +209,12 @@ std::optional 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) diff --git a/tests/Autocomplete.test.cpp b/tests/Autocomplete.test.cpp index 492f5b4d..3d36a6dd 100644 --- a/tests/Autocomplete.test.cpp +++ b/tests/Autocomplete.test.cpp @@ -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")