Skip to content

Update ps1 completion#3365

Merged
keith-hall merged 6 commits into
sharkdp:masterfrom
deflektor:update/CompletionPwsh
Aug 8, 2025
Merged

Update ps1 completion#3365
keith-hall merged 6 commits into
sharkdp:masterfrom
deflektor:update/CompletionPwsh

Conversation

@deflektor

Copy link
Copy Markdown
Contributor

Hi all,

Made an update to the default completion for ps1

  1. Removed shortcut entries
    Code completion, in powershell, should be more descriptive.
  2. Added completions with individual values for
    ** Language
    ** Theme
    ** Other argument with options

Works with Powershell Core 7

@keith-hall keith-hall requested a review from Copilot August 3, 2025 15:52

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR updates the PowerShell completion script for bat to provide more descriptive and comprehensive tab completion functionality. The update removes shortcut entries and adds dynamic completions with individual values for languages, themes, and other command arguments.

  • Replaced template placeholders with hardcoded "bat" command name
  • Added dynamic completion functions for themes and languages with descriptive output
  • Enhanced argument-specific completions with predefined value arrays for various options
Comments suppressed due to low confidence (1)

assets/completions/_bat.ps1.in:22

  • The variable name '$themes' is misleading since this function processes languages, not themes. It should be named '$languages' for clarity.
        $themes = bat --list-languages | ForEach-Object{[pscustomobject]@{MyParameter=$_.Substring(0,$_.IndexOf(":")).Trim();MyDescription=$_.Substring($_.IndexOf(":")+1)}} | select-object

Comment thread assets/completions/_bat.ps1.in Outdated
Comment thread assets/completions/_bat.ps1.in Outdated
Comment thread assets/completions/_bat.ps1.in Outdated
Comment on lines +34 to +35
$element.Value -eq $wordToComplete) {
#-or $element.Value.StartsWith('-')

Copilot AI Aug 3, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The condition logic appears incorrect. The original condition checked if the element starts with '-' OR equals $wordToComplete, but now it only checks equality. This could break command parsing logic.

Suggested change
$element.Value -eq $wordToComplete) {
#-or $element.Value.StartsWith('-')
$element.Value -eq $wordToComplete -or $element.Value.StartsWith('-')) {

Copilot uses AI. Check for mistakes.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems like Copilot missed that it was commented out previously?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changing back, would not complete the optional entries, I receive only the default part.

Comment thread assets/completions/_bat.ps1.in Outdated
Comment thread assets/completions/_bat.ps1.in Outdated
Comment thread assets/completions/_bat.ps1.in Outdated
@keith-hall keith-hall force-pushed the update/CompletionPwsh branch from 617dbcd to 2a92258 Compare August 8, 2025 02:48
@keith-hall keith-hall enabled auto-merge August 8, 2025 03:10
deflektor and others added 6 commits August 8, 2025 06:11
changed back to Template

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@keith-hall keith-hall force-pushed the update/CompletionPwsh branch from 2a92258 to d4fc07a Compare August 8, 2025 03:11
@keith-hall keith-hall merged commit c4d7451 into sharkdp:master Aug 8, 2025
22 of 23 checks passed
@deflektor deflektor deleted the update/CompletionPwsh branch August 10, 2025 10:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants