Skip to content

Commit 2f30724

Browse files
committed
Revert "Show auto-imports in array-like tables"
This reverts commit 9e8cf33. We are incorrectly showing auto imports when indexing tables with properties. A test is attached
1 parent 60c3dd4 commit 2f30724

File tree

3 files changed

+11
-9
lines changed

3 files changed

+11
-9
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
66

77
## [Unreleased]
88

9+
### Fixed
10+
11+
- Reverted "Fixed auto-imports not showing up when autocompleting in array-like tables" due to it incorrectly suggesting auto-imports when indexing tables (e.g., `local x = tbl.pro|`)
12+
913
## [1.56.0] - 2025-11-02
1014

1115
### Added
@@ -1710,6 +1714,7 @@ local y = tbl.data -- Should give "This is some special information"
17101714
### Added
17111715

17121716
- Added configuration options to enable certain Language Server features. By default, they are all enabled:
1717+
17131718
- `luau-lsp.completion.enabled`: Autocomplete
17141719
- `luau-lsp.hover.enabled`: Hover
17151720
- `luau-lsp.signatureHelp.enabled`: Signature Help

src/operations/Completion.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -761,8 +761,7 @@ std::vector<lsp::CompletionItem> WorkspaceFolder::completion(const lsp::Completi
761761

762762
if (config.completion.suggestImports || config.completion.imports.enabled)
763763
{
764-
if (result.context == Luau::AutocompleteContext::Expression || result.context == Luau::AutocompleteContext::Statement ||
765-
result.context == Luau::AutocompleteContext::Property)
764+
if (result.context == Luau::AutocompleteContext::Expression || result.context == Luau::AutocompleteContext::Statement)
766765
{
767766
suggestImports(moduleName, position, config, *textDocument, items, /* completingTypeReferencePrefix: */ false);
768767
}

tests/AutoImports.test.cpp

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1449,12 +1449,12 @@ TEST_CASE_FIXTURE(Fixture, "auto_import_empty_require_statement")
14491449
CHECK_EQ(item->additionalTextEdits[0].range.start.line, 1);
14501450
}
14511451

1452-
TEST_CASE_FIXTURE(Fixture, "auto_imports_shows_up_in_tables_before_equals_sign")
1452+
TEST_CASE_FIXTURE(Fixture, "auto_imports_shows_up_in_tables_after_equals_sign")
14531453
{
14541454
client->globalConfig.completion.imports.enabled = true;
14551455
auto [source, marker] = sourceWithMarker(R"(
14561456
create({
1457-
|
1457+
Key = |
14581458
})
14591459
)");
14601460

@@ -1468,13 +1468,11 @@ TEST_CASE_FIXTURE(Fixture, "auto_imports_shows_up_in_tables_before_equals_sign")
14681468
CHECK(getItem(result, "ReplicatedStorage"));
14691469
}
14701470

1471-
TEST_CASE_FIXTURE(Fixture, "auto_imports_shows_up_in_tables_after_equals_sign")
1471+
TEST_CASE_FIXTURE(Fixture, "auto_imports_do_not_show_when_completion_property")
14721472
{
14731473
client->globalConfig.completion.imports.enabled = true;
14741474
auto [source, marker] = sourceWithMarker(R"(
1475-
create({
1476-
Key = |
1477-
})
1475+
local x = foo.ba|
14781476
)");
14791477

14801478
auto uri = newDocument("foo.luau", source);
@@ -1484,7 +1482,7 @@ TEST_CASE_FIXTURE(Fixture, "auto_imports_shows_up_in_tables_after_equals_sign")
14841482
params.position = marker;
14851483

14861484
auto result = workspace.completion(params, nullptr);
1487-
CHECK(getItem(result, "ReplicatedStorage"));
1485+
CHECK_FALSE(getItem(result, "ReplicatedStorage"));
14881486
}
14891487

14901488
TEST_SUITE_END();

0 commit comments

Comments
 (0)