Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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