Skip to content

Commit

Permalink
Fix automatic requires being placed inside of comment
Browse files Browse the repository at this point in the history
Fixes #327
  • Loading branch information
JohnnyMorganz committed Mar 23, 2023
1 parent dba3089 commit 1acf6e5
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 6 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).

- Fixed server crash when auto require imports is enabled and there is a type-asserted require present in the file (`require(location) :: any`)
- Fixed additional automatic service imports when completing an automatic require import being placed before a hot comment (such as `--!strict`)
- 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.

## [1.18.0] - 2023-03-20

Expand Down
7 changes: 1 addition & 6 deletions src/operations/Completion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -379,15 +379,10 @@ void WorkspaceFolder::suggestImports(const Luau::ModuleName& moduleName, const L
if (!isRelative)
{
// Service will be the first part of the path
// If we haven't imported the service already, then we auto-import it
auto service = requirePath.substr(0, requirePath.find('/'));
if (serviceVisitor.serviceLineMap.find(service) == serviceVisitor.serviceLineMap.end())
{
// If we haven't imported the service, then we auto-import it
textEdits.emplace_back(createServiceTextEdit(service, serviceVisitor.findBestLine(service, hotCommentsLineNumber)));

// Increment the require line number to account for the new service import
lineNumber += 1;
}
}

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

0 comments on commit 1acf6e5

Please sign in to comment.