Skip to content
This repository has been archived by the owner on Dec 15, 2022. It is now read-only.

Snippets Trigger while Typing in Tab Stops #293

Closed
1 task done
HackingHackers opened this issue Oct 1, 2019 · 6 comments
Closed
1 task done

Snippets Trigger while Typing in Tab Stops #293

HackingHackers opened this issue Oct 1, 2019 · 6 comments

Comments

@HackingHackers
Copy link

Prerequisites

Steps to Reproduce

  1. Type "for" and hit tab to insert the "For Loop" snippet
    Typing "for"

The "For Loop" snippet

  1. If you type something like "in" that contains a snippet's prefix, the snippet suggestion pops up

Autocomplete

  1. Then if you want to switch to the next tab stop by pressing tab, the snippet will come out and you can't go to the next tab stop (count)

Snippet

Expected behavior:

The snippet suggestion will not pop up in autocomplete while typing in a tab stop.

OR

After completing the snippet in the tab stop, you can still press tab to switch to the next tab stop in the original snippet.

Actual behavior:

The snippet comes out if you press tab and you can't switch to the next tab stop in the original snippet

Reproduces how often:

When you type something that contains a snippet prefix.

Versions

atom --version
Atom : 1.40.1
Electron : 3.1.10
Chrome : 66.0.3359.181
Node : 10.2.0

apm --version
apm 2.4.3
npm 6.2.0
node 10.2.1 x64
atom 1.40.1
python 2.7.16
git 2.21.0

OS
macOS Catalina Beta 8 (19A558d)

@rsese rsese transferred this issue from atom/atom Oct 2, 2019
@rsese
Copy link

rsese commented Oct 2, 2019

Thanks for contributing!

We noticed that this looks like a duplicate of #152 so you can subscribe there if you'd like.


Because we treat our issues list as the Atom team's backlog, we close duplicates to focus our work and not have to touch the same chunk of code for the same reason multiple times. This is also why we may mark something as duplicate that isn't an exact duplicate but is closely related.

For information on how to use GitHub's search feature to find out if something is a duplicate before filing, see the How Can I Contribute? section of the Atom CONTRIBUTING guide.

@rsese rsese closed this as completed Oct 2, 2019
@rsese rsese added the duplicate label Oct 2, 2019
@savetheclocktower
Copy link
Contributor

I would not necessarily have considered this a duplicate of #152, but they're both illustrations of the problem of what to do when typing inside of a tab stop. In general, an editor shouldn't stop suggesting snippets simply because the user is already moving through another snippet's tab stops. I could be persuaded that it makes sense as a package setting so that people who feel strongly about it can disable the behavior globally.

In your example, @HackingHackers, you've got some options. You could change the “Keymap for Confirming a Selection” option in the autocomplete-plus package settings, so that Tab no longer automatically selects the first item just because it comes up as a suggestion. You could increase the delay before suggestions are shown. You could disable the autocomplete-snippets package altogether if you don't like it when snippets are offered as autocomplete suggestions.

I get why autocomplete-snippets offers up suggestions on partial prefix matches — it aids discoverability — but it'd be nice if that didn't also opt you into the “accidental default” behavior that's being described. Not sure how to thread that needle. But I'd argue that this is a problem with how autocompletion behaves, not with how the snippets package itself behaves.

@rsese
Copy link

rsese commented Oct 3, 2019

Thanks @savetheclocktower - happy to defer to you on this because of all the work you've done with snippets 👍

So just to clarify, you think think this is an issue for https://github.com/atom/autocomplete-snippets? If so, I can transfer this issue over to that package.

@savetheclocktower
Copy link
Contributor

Nah, I wasn't trying to second-guess the decision; just offering some context.

I don't think this is an issue for autocomplete-snippets; I can't think of anything they could do to fix the underlying problem. The problem is that Tab functions as a way of selecting the default choice when the autocomplete menu comes up, but Tab is also the default keystroke for switching between tabstops. @HackingHackers describes a scenario where they want Tab to do the second thing, but it's doing the first thing.

Both autocomplete-plus and snippets want to use Tab, but they both want that key because that's how both features have historically worked, so I don't think it's a problem — just an inherent conflict based on design decisions. I can't identify one particular thing that would fix this issue; just a bunch of possible workarounds which each user has to decide between. (In my case I just disabled autocomplete-snippets. 😄)

@rsese
Copy link

rsese commented Oct 7, 2019

Gotcha, thanks for the extra context 🙇 And thanks for the suggested workarounds, super helpful for folks that run into this conflict.

@HackingHackers
Copy link
Author

Thanks @savetheclocktower for your helpful suggestions. I've changed my "Keymap For Confirming A Suggestion" in the autocomplete-plus package and it works well.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants