Skip to content

Commit

Permalink
Little code style cleanup for the GetCompletions() method (#3898)
Browse files Browse the repository at this point in the history
  • Loading branch information
daxian-dbw authored Dec 11, 2023
1 parent f2207f4 commit e57f7d6
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions PSReadLine/Completion.cs
Original file line number Diff line number Diff line change
Expand Up @@ -288,16 +288,27 @@ private CommandCompletion GetCompletions()
ps = System.Management.Automation.PowerShell.Create();
ps.Runspace = _runspace;
}
_tabCompletions = _mockableMethods.CompleteInput(_buffer.ToString(), _current, null, ps);

if (_tabCompletions.CompletionMatches.Count == 0) return null;
_tabCompletions = _mockableMethods.CompleteInput(_buffer.ToString(), _current, null, ps);
if (_tabCompletions.CompletionMatches.Count == 0)
{
return null;
}

// Validate the replacement index/length - if we can't do
// the replacement, we'll ignore the completions.
var start = _tabCompletions.ReplacementIndex;
var length = _tabCompletions.ReplacementLength;
if (start < 0 || start > _singleton._buffer.Length) return null;
if (length < 0 || length > (_singleton._buffer.Length - start)) return null;

if (start < 0 || start > _singleton._buffer.Length)
{
return null;
}

if (length < 0 || length > (_singleton._buffer.Length - start))
{
return null;
}
}
catch (Exception)
{
Expand Down

0 comments on commit e57f7d6

Please sign in to comment.