mirror of
https://github.com/Microsoft/vscode
synced 2024-08-27 13:00:58 +00:00
Merge pull request #215581 from microsoft/tyriar/211996
Add . and .. to suggestions, do nothing is completing same
This commit is contained in:
commit
ed0a90c0b1
|
@ -212,7 +212,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));
|
||||
|
|
|
@ -81,10 +81,6 @@ export const events = [
|
|||
"type": "command",
|
||||
"id": "workbench.action.terminal.acceptSelectedSuggestion"
|
||||
},
|
||||
{
|
||||
"type": "sendText",
|
||||
"data": "s"
|
||||
},
|
||||
{
|
||||
"type": "output",
|
||||
"data": "\u001b[?25l\u001b[93m\u001b[3;3Hls\u001b[97m\u001b[2m\u001b[3ms\b\u001b[?25h"
|
||||
|
|
Loading…
Reference in a new issue