mirror of
https://github.com/Microsoft/vscode
synced 2024-08-27 13:00:58 +00:00
Add . and .. to suggestions, do nothing is completing same
Fixes #211996
This commit is contained in:
parent
8fdbb81a9f
commit
ce3f763edb
|
@ -207,7 +207,19 @@ function Send-Completions {
|
|||
$completions = TabExpansion2 -inputScript $completionPrefix -cursorColumn $cursorIndex
|
||||
if ($null -ne $completions.CompletionMatches) {
|
||||
$result += ";$($completions.ReplacementIndex);$($completions.ReplacementLength);$($cursorIndex);"
|
||||
$result += $completions.CompletionMatches | ConvertTo-Json -Compress
|
||||
if ($completions.CompletionMatches.Count -gt 0 -and $completions.CompletionMatches.Where({ $_.ResultType -eq 3 -or $_.ResultType -eq 4 })) {
|
||||
$json = [System.Collections.ArrayList]@($completions.CompletionMatches)
|
||||
# Add . and .. to the completions list
|
||||
$json.Add([System.Management.Automation.CompletionResult]::new(
|
||||
'.', '.', [System.Management.Automation.CompletionResultType]::ProviderContainer, (Get-Location).Path)
|
||||
)
|
||||
$json.Add([System.Management.Automation.CompletionResult]::new(
|
||||
'..', '..', [System.Management.Automation.CompletionResultType]::ProviderContainer, (Split-Path (Get-Location) -Parent))
|
||||
)
|
||||
$result += $json | ConvertTo-Json -Compress
|
||||
} else {
|
||||
$result += $completions.CompletionMatches | ConvertTo-Json -Compress
|
||||
}
|
||||
}
|
||||
}
|
||||
# If there is no space, get completions using CompletionCompleters as it gives us more
|
||||
|
|
|
@ -267,6 +267,7 @@ export class SuggestAddon extends Disposable implements ITerminalAddon, ISuggest
|
|||
if (!Array.isArray(completionList)) {
|
||||
completionList = [completionList];
|
||||
}
|
||||
|
||||
const completions = completionList.map((e: any) => {
|
||||
return new SimpleCompletionItem({
|
||||
label: e.ListItemText,
|
||||
|
@ -278,6 +279,7 @@ export class SuggestAddon extends Disposable implements ITerminalAddon, ISuggest
|
|||
|
||||
this._leadingLineContent = this._promptInputModel.value.substring(0, this._promptInputModel.cursorIndex);
|
||||
|
||||
|
||||
// If there's no space it means this is a command, add cached commands list to completions
|
||||
const firstChar = this._leadingLineContent.length === 0 ? '' : this._leadingLineContent[0];
|
||||
if (this._leadingLineContent.trim().includes(' ') || firstChar === '[') {
|
||||
|
@ -503,6 +505,12 @@ export class SuggestAddon extends Disposable implements ITerminalAddon, ISuggest
|
|||
const completionText = completion.completionText ?? completion.label;
|
||||
const finalCompletionRightSide = completionText.substring((this._leadingLineContent?.length ?? 0) - (lastSpaceIndex === -1 ? 0 : lastSpaceIndex + 1));
|
||||
|
||||
// Hide the widget if there is no change
|
||||
if (finalCompletionRightSide === additionalInput) {
|
||||
this.hideSuggestWidget();
|
||||
return;
|
||||
}
|
||||
|
||||
// Get the final completion on the right side of the cursor if it differs from the initial
|
||||
// propmt input state
|
||||
let finalCompletionLeftSide = completionText.substring(0, (this._leadingLineContent?.length ?? 0) - (lastSpaceIndex === -1 ? 0 : lastSpaceIndex + 1));
|
||||
|
|
Loading…
Reference in a new issue