Skip to content

Promote snippets over other suggestions - #5121

Closed
Stanislav Sysoev (d4rkr00t) wants to merge 1 commit into
microsoft:masterfrom
d4rkr00t:suggestion-score
Closed

Stanislav Sysoev (d4rkr00t) wants to merge 1 commit into
microsoft:masterfrom
d4rkr00t:suggestion-score

Conversation

@d4rkr00t

Copy link
Copy Markdown

What do you think about promoting snippets over other suggestions?

I think it might be useful because:

  • Snippets's huge productivity booster and fast access to them is important.
  • When snippets this deep in suggestions list they're almost useless because it's almost impossible to find them.

Examples:

Current behaviour:
before

After changes from pull request:
after

Atom for comparison:
atom

Possibly issue in another place:

Because in empty file snippets already in the most top of suggestions:
empty

I've tested in:
Code 0.10.14-insider, 0.10.11 (stable) and manual build from master branch.
OSX: 10.11.3

@msftclas

Hi Stanislav Sysoev (@d4rkr00t), I'm your friendly neighborhood Microsoft Pull Request Bot (You can call me MSBOT). Thanks for your contribution!

In order for us to evaluate and accept your PR, we ask that you sign a contribution license agreement. It's all electronic and will take just minutes. I promise there's no faxing. https://cla.microsoft.com.

TTYL, MSBOT;

@msftclas

Stanislav Sysoev (@d4rkr00t), Thanks for signing the contribution license agreement so quickly! Actual humans will now validate the agreement and then evaluate the PR.

Thanks, MSBOT;

@te1

Copy link
Copy Markdown

Thank you Stanislav Sysoev (@d4rkr00t) for that PR! ❤️
This has been bugging me for a long time and is the only remaining reason VS Code is not my main editor yet. I tried to articulate this in #2343 as well.

I really hope this gets merged soon.

@d4rkr00t

Copy link
Copy Markdown
Author

te (@te1) glad to here that you find it useful.

@dstorey

Copy link
Copy Markdown
Member

I’d hate this for CSS. The snippets are almost never what I want to use, especially when completing CSS values (the predefined are all properties), so this would worsen the user experience.

@d4rkr00t

Copy link
Copy Markdown
Author

In CSS it's usually more convenient to use emmet shortcuts then autocompletion. But in JS it's so annoying that you have to type things again and again. Especially things like function or for. I definitely do not want keyword for when i've already typed it.

However with last vscode update it became better, I don't know why. But now, in maybe half cases, vscode suggests me snippets, but not always. Example down below:

out

@alexdima

Copy link
Copy Markdown
Member

Sorry I didn't reply earlier on this PR, I was on vacation for a couple of weeks. I think Johannes Rieken (@jrieken) owns the experience in this area more than I do.

@d4rkr00t

Copy link
Copy Markdown
Author

It's okay. Vacation is important :)

@jrieken

Copy link
Copy Markdown
Contributor

Very unlikely that we merge this. As already mentioned people are very sensitive to this and changing the sort order to boost snippets isn't what everyone wants.

I can think of a special command that only suggest snippets or an extension that does that.

@jrieken Johannes Rieken (jrieken) added this to the May 2016 milestone Apr 26, 2016
@te1

Copy link
Copy Markdown

I tend to agree that there will be situations where you don't want snippets to show up first in the suggestion list (e.g. CSS). Still every other editor in recent memory I tried is more productive for me when using snippets because it works as I would expect.

Sublime Text has the concept of a tab trigger that activates if you press tab and the sequence of letters matches exactly. VS Code's prefix is more like a name for the snippet that is used to place it somewhere appropriate in the suggestion list along with all the other names (keywords, symbols, ...). If your prefix is long and unique there is no problem. But if your prefix is short and similar or even identical to other names there is a good chance you have to manually select the snippet from the suggestion list which for me reduces productivity immensely.

Example: In an empty JavaScript file write if and press tab. I would expect the if snippet to be triggered. Instead most of the time it will auto complete to the if keyword because it has a higher priority. Both are exact matches but one does what I would expect (snippet) and the other does effectively nothing (keyword).

This PR basically implements the tab trigger mechanism but has the side effect that the suggestion list priorities are changed as well. Maybe there is a way to implement the tab trigger in addition to the existing suggestion list approach and make it optional?

A special command probably wouldn't work for me because I still want to invoke both snippet insertion and code completion by pressing tab. I would prefer a built in solution for this common problem but would be fine with an extension as well. My understanding of the VS Code extension API is unfortunately very limited so I can't even tell if an extension would be able to do what I want.

I realize there are different opinions on this topic but this is a real pain point for me. Other editors appear to have solved this in a way that makes most users happy.

@d4rkr00t

Copy link
Copy Markdown
Author

Johannes Rieken (@jrieken) I see. It's ok :)

Idea about extension sounds great to me. I'll definitely try to implement it. I'm not sure if I can get all snippets for current language inside extension, but I'll find out :).

Moreover a special command wouldn't be convenient way for me, I would prefer to use tab trigger. Because, in my opinion, it should be the same mechanism as in suggestions and should work seamlessly to other editors.

@te1

Copy link
Copy Markdown

Just a quick note about this PR: It only promotes snippets to the top if there is an exact match between what has been typed and the prefix for a certain snippet from what I understand. This is not made clear in the description. Instead it sounds like all snippets are given priority all the time which would indeed bother some people.

So in the end this PR is not as invasive as it may seem. Just something to consider before a final decision is made.

@d4rkr00t

Copy link
Copy Markdown
Author

It actually changes order of suggestions https://github.com/Microsoft/vscode/pull/5121/files#diff-518e736f78c3288400a5d064bb875c59L71. But I can remove this code and It'll still work and than there is no need to change tests.

@jrieken

Copy link
Copy Markdown
Contributor

I will bring this up in the team discussion and then we'll see how we go forward. Snippets mixed with suggestions is a point of discussion. Expect a little delay cos public holiday and long weekend is around the corner.

@keelii

Copy link
Copy Markdown

Just wating for this PR merged ❤️

@kumarharsh

Copy link
Copy Markdown
Contributor

Johannes Rieken (@jrieken) for me the ordering of the suggestions is mostly not useful when I'm writing react code. For example, I write PropTypes.xxx.isRequired a lot in the static propTypes: {} property of each class. But every time, vscode suggests PropertyDecorator which I've never used in my life.

screenshot 228

Can we have a better listing which learns by usage and is atleast 80% useful, rather than a fixed list which is not so useful?

@filipesilva

Copy link
Copy Markdown

Johannes Rieken (@jrieken) perhaps a configurable option to always have them on top/bottom/auto would satisfy everyone?

@jrieken

Copy link
Copy Markdown
Contributor

yes - it might something like that in the end

@empz

Copy link
Copy Markdown

What about suggesting snippets first only if cursor is in an empty line? Would that make sense?

I actually want snippets to not even show (or show at the bottom at least) inside an object literal where properties should be the only thing showing up in the intellisense.
Right now snippets are showing everywhere which I think makes no sense at all.
image

@jrieken

Copy link
Copy Markdown
Contributor

We will tackle this in #9286. Closing this PR in favour of configuration options for snippets, like top, bottom, normal, none

@d4rkr00t

Copy link
Copy Markdown
Author

Wow, great 👍

@jrieken

Johannes Rieken (jrieken) commented Jul 21, 2016 •

Copy link
Copy Markdown
Contributor

Everyone, please feel free to provide feedback for

Thanks

@github-actions github-actions Bot locked and limited conversation to collaborators Mar 27, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

10 participants