Skip to content

Remove cmdlet/cmd that error from history to reduce confusion #3517

Open

Description

Prerequisites

  • Write a descriptive title.

Description of the new feature/enhancement

When there is a cmdlet or command that errors, we should utilize the experimental feedback provider (or other method) to recognize that it was in fact an error and then remove the last line from the history PSReadLine uses for history predictions. This way historical predictions can only suggest commands that were successful. This should not remove it from the session history, only the PSReadLine history

Some questions:

  • Are erroring commands distracting for the user to have in history predictions?
  • Is it confusing for a failed command to not show up in history for users?

Proposed technical implementation details (optional)

No response

Activity

  1. ghost added
    Needs-Triage 🔍It's a new issue that core contributor team needs to triage.
    on Dec 19, 2022
  2. daxian-dbw commented on Feb 6, 2023

    @daxian-dbw
    Member

    Are erroring commands distracting for the user to have in history predictions?

    Not necessarily in my opinion. When the execution of a command line failed, it doesn't necessarily mean the command line itself has problem -- it could be some context state is different in this session, such as Az account not logged in yet, or Az context is with a different subscription, or even a variable used in this command line was not populated beforehand, and etc.

    Command line execution failure from those scenarios are not distracting and should be put in history files, otherwise it will be a surprise to the user.

    In most cases, execution failure because of typo in command name is distracting in history prediction, but PSReadLine already provides a way for users to register a validation handler before returning the command-line to PowerShell engine for execution, also there is history saving handler, which users can customize whether they want to save a particular command line to history or not.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Area-HistoryImprovementsLabel for tracking different improvements to historyArea-PredictorsLabel for issues related to predictorsIssue-EnhancementIt's a feature request.

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions