Skip to content

Commit 1acf6e5

Browse files
committed
Fix automatic requires being placed inside of comment
Fixes #327
1 parent dba3089 commit 1acf6e5

File tree

2 files changed

+2
-6
lines changed

2 files changed

+2
-6
lines changed

CHANGELOG.md

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

1111
- Fixed server crash when auto require imports is enabled and there is a type-asserted require present in the file (`require(location) :: any`)
1212
- Fixed additional automatic service imports when completing an automatic require import being placed before a hot comment (such as `--!strict`)
13+
- Fixed automatic require import being placed incorrectly we also autocomplete a service. This can be shown when there is a multiline comment, and the service is imported above that comment, but the require gets imported inside of the comment incorrectly.
1314

1415
## [1.18.0] - 2023-03-20
1516

src/operations/Completion.cpp

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -379,15 +379,10 @@ void WorkspaceFolder::suggestImports(const Luau::ModuleName& moduleName, const L
379379
if (!isRelative)
380380
{
381381
// Service will be the first part of the path
382+
// If we haven't imported the service already, then we auto-import it
382383
auto service = requirePath.substr(0, requirePath.find('/'));
383384
if (serviceVisitor.serviceLineMap.find(service) == serviceVisitor.serviceLineMap.end())
384-
{
385-
// If we haven't imported the service, then we auto-import it
386385
textEdits.emplace_back(createServiceTextEdit(service, serviceVisitor.findBestLine(service, hotCommentsLineNumber)));
387-
388-
// Increment the require line number to account for the new service import
389-
lineNumber += 1;
390-
}
391386
}
392387

393388
textEdits.emplace_back(createRequireTextEdit(node->name, require, lineNumber));

0 commit comments

Comments
 (0)