Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow sendInput to have promptable sections for further completion #12927

Open
Tracked by #15845
zadjii-msft opened this issue Apr 18, 2022 · 0 comments
Open
Tracked by #15845

Allow sendInput to have promptable sections for further completion #12927

zadjii-msft opened this issue Apr 18, 2022 · 0 comments
Labels
Area-CmdPal Command Palette issues and features Area-Extensibility A feature that would ideally be fulfilled by us having an extension model. Area-Settings Issues related to settings and customizability, for console or terminal Issue-Feature Complex enough to require an in depth planning process and actual budgeted, scheduled work. Product-Terminal The new Windows Terminal.
Milestone

Comments

@zadjii-msft
Copy link
Member

zadjii-msft commented Apr 18, 2022

This is like half a showerthought.

Probably refer to

What if sendInput could have like, a ${prompt} section in it, that then had the terminal prompt you to complete that section before actually doing the whole sendInput? So you could have like (for trivial example):

"command": 
{
    "action": "sendInput",
    "input": "git checkout ${prompt}"
},

Okay now hear me out for where we get extra crazy.

Crazy idea A

You can label these sections, and we'd fill in subsequent ones if you fill in the first:

"command": 
{
    "action": "sendInput",
    "input": "git checkout ${prompt branch} & echo 'switched to branch ${prompt branch}'"
},

This part is definitely inspired by macros in Sublime Text, where I know you can label individual bits as being the same thing.

Crazy idea B

We annotate these sections, and try to provide intelligent completions for them. Like say

"command": 
{
    "action": "sendInput",
    "input": "robocopy ${prompt source:dir} ${prompt target:dir} /mir"
},

So when we see :dir, we know that we're supposed to autofill a path into there. That could even be tied into the shell location (OSC9;9) to provide context-sensitive completion.

Crazy idea C

Building on B, what if apps could provide their own completions to us?

"command": 
{
    "action": "sendInput",
    "input": "git checkout ${prompt branch:git-branch} & echo 'switched to branch ${prompt branch}'"
},

// elsewhere in the settings
"git-branch": "git for-each-ref --format=%(refname:short) refs/heads/"

addenda

  • Are these not basically just shell aliases?
  • Would this not just make more sense as a shell feature? The shell already knows things about where the CWD is. It can do directories and stuff. Maybe it makes more sense to just let WT conveniently manage your aliases for different shells?
  • Obviously CMD is terrible so it'll never get anything like this.
  • Could we make them CWD-specific? Like, context sensitive?

Crazy idea D

basically like C, but more scriptable?

I propose to extend sendInput command (#3799) . At present, it allows to pass String input, which should be displayed on the terminal. I want to execute a code and display the result, instead of static text.

For example, I want to insert a current git branch to the current terminal cursor position. I can get the name with help git rev-parse --abbrev-ref HEAD. So, I would like to have the following hotkey in the terminal:

{
  "command": {
    "action": "sendInput",
    "input": $(git rev-parse --abbrev-ref HEAD), or ./get-branch-name.exe
  },
  "keys": "ctrl+k"
}

At present, I cannot do it, because input accepts only strings. There are a few workarounds, like, "input": "git rev-parse --abbrev-ref HEAD| Set-Clipboard\r, but they don't allow to insert needed input in place.

Crazy idea E

What if it was just the .vscode/tasks.json syntax?

@ghost ghost added Needs-Triage It's a new issue that the core contributor team needs to triage at the next triage meeting Needs-Tag-Fix Doesn't match tag requirements labels Apr 18, 2022
@zadjii-msft zadjii-msft added Issue-Feature Complex enough to require an in depth planning process and actual budgeted, scheduled work. Area-Extensibility A feature that would ideally be fulfilled by us having an extension model. Area-Settings Issues related to settings and customizability, for console or terminal Product-Terminal The new Windows Terminal. Area-CmdPal Command Palette issues and features and removed Needs-Triage It's a new issue that the core contributor team needs to triage at the next triage meeting labels Apr 19, 2022
@ghost ghost removed the Needs-Tag-Fix Doesn't match tag requirements label Apr 19, 2022
@zadjii-msft zadjii-msft added this to the Backlog milestone Apr 19, 2022
zadjii-msft added a commit that referenced this issue Oct 5, 2023
## Summary of the Pull Request

> ## Abstract
> 
> Multiple related scenarios have come up where it would be beneficial
to display
> actionable UI to the user within the context of the active terminal
itself. This
> UI would be akin to the Intellisense UI in Visual Studio. It appears
right where
> the user is typing, and can help provide immediate content for the
user, based
> on some context. The "Suggestions UI" is this new ephemeral UI within
the
> Windows Terminal that can display different types of actions, from
different
> sources.
> 


## Detailed Description of the Pull Request / Additional comments

_\*<sup>\*</sup><sub>\*</sub> read the spec
<sub>\*</sub><sup>\*</sup>\*_

Similar to #14792, a lot of this code is written. This stuff isn't
checked in though, so I'm presenting formally before I start yeeting PRs
out there.

## PR Checklist
- [x] This is a spec for #1595. It also references:
  * #3121
  * #10436
  * #12927
  * #12863
github-merge-queue bot pushed a commit that referenced this issue Jun 22, 2024
This specs out a lot of plans for snippets. We've already got these in
the sxnui as "tasks", but we can do so very much more.

This spec is a few years old now, but it's time for it to get promoted
out of my draft branch.

References: 
* #1595
* #7039
* #3121
* #10436
* #12927
* #12857
* #5790
* #15845

---------

Co-authored-by: Dustin L. Howett <duhowett@microsoft.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-CmdPal Command Palette issues and features Area-Extensibility A feature that would ideally be fulfilled by us having an extension model. Area-Settings Issues related to settings and customizability, for console or terminal Issue-Feature Complex enough to require an in depth planning process and actual budgeted, scheduled work. Product-Terminal The new Windows Terminal.
Projects
None yet
Development

No branches or pull requests

1 participant