Skip to content

draft of abbreviation expansion tab completion #150

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

Merged
merged 4 commits into from
Jan 29, 2019

Conversation

SteveL-MSFT
Copy link
Member

No description provided.

@TylerLeonhardt
Copy link
Member

Excited to see this. It's going to save a lot of keystrokes with Azure PowerShell.

I came here to request one other case that is handled.

Allow for the verb side of the dash to be either just the capital letters, or the alias of the verb

Here's an example:

Start-AzureHDInsightJob and Stop-AzureHDInsightJob

Using just the capital letters, they would both resolve still:

s-ahdij

However, if we could specify the alias of the verb as well, we can easily differentiate:

sa-ahdij vs sp-ahdij

This is just one example... But there are a decent amount of verbs that compliment each other that have the same capital letters:

Start and Stop
Push and Pop
Install and Import
etc

Leveraging the verb alias will save the user time here.

Like I said, this is in addition to strictly capital letters. Not a replacement.

@KirkMunro
Copy link
Contributor

Also excited to see this, but wonder if this is enough. Is the intent here to save typing? Or to make command discovery easier? Or both? Right now this seems designed to save typing for users who know command names, but if I'm thinking through the capital letters in camel case I bet I could type the command almost as quickly as I think it through to break it down. And given the sheer volume of commands available, I wonder how much time this will actually save.

What about building an index of commands using the "words" (taken from camel case naming), and then in tab completion breaking up a sequence of characters into those words and finding matches, such that azsql<tab> would find all commands that have the Az and Sql words in them. Combining something like that with partial matches, and looking for something like New-AzSqlServerDisasterRecoveryConfiguration, maybe you could simply enter New-AzSqlRecovConfig<tab> and get the right matches presented to you.

@vors
Copy link
Contributor

vors commented Nov 4, 2018

Great proposal! I believe there is a way to take it even further and accommodate both @tylerl0706 and @KirkMunro suggestions: fuzzy search. It specifically favors the original proposal (capital letters) and also adds the additional flexibility in a general way.

There are plenty of implementations on GitHub, but they are mostly in JS. Here is a good article that described the sublime fuzzy search algorithm https://blog.forrestthewoods.com/reverse-engineering-sublime-text-s-fuzzy-match-4cffeed33fdb

@TylerLeonhardt
Copy link
Member

@vors makes an excellent point. Fuzzy search is super common today in a lot of editors - in fact, VSCode supplies fuzzy search for intellisense today (for all languages including PowerShell).

@dfinke
Copy link

dfinke commented Nov 4, 2018

I started playing around with fuzzy search. I think I lifted the regex approach from sublime. https://github.com/dfinke/PowerShellFuzzySearch

@iSazonov
Copy link
Contributor

iSazonov commented Nov 6, 2018

Initial propose looks as difficult to discover by users. I guess any user expect that it is possible to type a word and then get variants by tab. I think that @KirkMunro 's suggestion is best start. I'd start with it and then wait a feedback for should we also add search by patterns like s*-az* or not.

@vors
Copy link
Contributor

vors commented Nov 6, 2018

There are a lot of great ideas and it's unclear what would work the best (and perhaps different people have different needs / styles). Can we introduce a string / enum variable $PSTabCompletionStrategy that people can set and pick their favorite? At least that would be useful for the evaluation period so we can move forward to playing with something working.

@iSazonov
Copy link
Contributor

iSazonov commented Nov 7, 2018

Can we introduce a string / enum variable $PSTabCompletionStrategy that people can set and pick their favorite?

Currently we can implement this as an experimental feature(s).

@SteveL-MSFT
Copy link
Member Author

This RFC as it's written is already submitted as a Experimental Feature PR you can try out right now. I like some of the suggestions, but wonder if, as @iSazonov alluded, they would be separate features (which could be used together).

@joeyaiello
Copy link
Contributor

LGTM

@joeyaiello joeyaiello merged commit 7ba80b9 into PowerShell:master Jan 29, 2019
@SteveL-MSFT SteveL-MSFT deleted the abbreviation-expansion branch January 30, 2019 00:22
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.

7 participants