Skip to content

Commit

Permalink
Improve auto-includes for code completion
Browse files Browse the repository at this point in the history
Signed-off-by: Ben Sherman <[email protected]>
  • Loading branch information
bentsherman committed Dec 4, 2024
1 parent dc40cfe commit cdc10fd
Showing 1 changed file with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -365,8 +365,10 @@ private boolean isIncluded(URI uri, MethodNode node) {

private Range getAddIncludeRange(URI uri) {
var includeNodes = ast.getIncludeNodes(uri);
if( includeNodes.isEmpty() )
return new Range(new Position(1, 0), new Position(1, 0));
if( includeNodes.isEmpty() ) {
var line = ast.getScriptNode(uri).getShebang() != null ? 1 : 0;
return new Range(new Position(line, 0), new Position(line, 0));
}
var lastInclude = includeNodes.get(includeNodes.size() - 1);
var lastIncludeRange = LanguageServerUtils.astNodeToRange(lastInclude);
var includeLine = lastIncludeRange != null ? lastIncludeRange.getEnd().getLine() + 1 : 0;
Expand Down

0 comments on commit cdc10fd

Please sign in to comment.