# snippets: Fix \<tab\> not working when at end of snippet \(\#11740\) · gitcafe/zed

[View on GitCafe](https://git.cafe/gitcafe/zed/commit/1afcd12747fea97e2f5bba254919e33006142da0)

Repository: [gitcafe/zed](https://git.cafe/gitcafe/zed)

Visibility: public

Requested revision: 1afcd12747fea97e2f5bba254919e33006142da0

Requested commit: 1afcd12747fea97e2f5bba254919e33006142da0

Commit: 1afcd12747fea97e2f5bba254919e33006142da0

Tree: 55cf5901e17850c52ec6752526f3ce0a68faa020

Author: Thorsten Ball

Committer: GitHub

## Message

```
snippets: Fix <tab> not working when at end of snippet (#11740)

This fixes #10185 by not keeping snippet state around when already at
the end of the snippet and the tabstop is empty (i.e. it's not a
selection) and we're already on it.

The reason for the fix is outlined in the comments of #10185 but to
repeat:

1. `gopls` sends completions with type "snippet" even when suggesting
single word completions that don't contain tabstops
2. We use a default behavior and add an "end tabstop" by default so that
the cursor jumps to the end of the snippet when accepting it.
3. We'd then push the state of the snippet on the stack which is where
it would stay, with the cursor already at the end and the user unable to
get rid of the tabstop state.

This fixes the issue by not pushing snippet state when the tabstop we
accepted is the "end tabstop".

Release Notes:

- Fixed completions inside snippets breaking the jump-to-next-tabstop
behaviour when using Go/`gopls`
([#10185](https://github.com/zed-industries/zed/issues/10185)).

Demo:



https://github.com/zed-industries/zed/assets/1185253/35384e5e-45c6-46ab-870d-b48e56d8786b
```

## Parents

- [6df1bc85aa44f7da6dd105f302fd14ac70f2f7d2](https://git.cafe/gitcafe/zed/commit/6df1bc85aa44f7da6dd105f302fd14ac70f2f7d2?format=markdown)

[Source at this commit](https://git.cafe/gitcafe/zed/tree/1afcd12747fea97e2f5bba254919e33006142da0?format=markdown)
