Skip to content

add tabstops to translations variables#1167

Merged
FKauwe merged 1 commit intomainfrom
add-tabstops-to-translations-variables
Mar 31, 2026
Merged

add tabstops to translations variables#1167
FKauwe merged 1 commit intomainfrom
add-tabstops-to-translations-variables

Conversation

@FKauwe
Copy link
Copy Markdown
Contributor

@FKauwe FKauwe commented Mar 27, 2026

What are you adding in this PR?

This fix adds tabstops to all the translation completions-- after selecting the autocomplete label from the dropdown, and pressing tab, the editor will now highlight the variable text to be filled by the user and the user will be able to type directly into this space, then tab forward and write text over the next variable (if there are multiple variables).
This will only work for translations that have variables.

I wrote a new function in translations.ts that creates the string with the Snippet syntax. There are Plain Text strings and Snippet strings, the previously used function returned PlainText and the tabstops behavior is only available on a Snippet.

The function gets called in the TranslationCompletionProvider and the insertTextFormat flag also gets set to Snippet now, so the editor knows to interpret the string as Snippet and surface the tabstops behavior to the user.

The existing spec file passes with my change and I added a new test to verify the new behavior

Fixes #537

How to Tophat

Off of main (old behavior): To trigger the translation key autocomplete with variables, go to any .liquid file and type:
{{ 'search.res
and pause for autocomplete to pop up. Select search.results_for_html and accept it, then notice that the variables are not highlighted and must be selected manually to be typed over (screenshots are in the linked ticket)
To see the new behavior, pull down my branch, function F5 to open the Extension Development instance in any theme and repeat the process. Now you should see the variables highlighted, with the ability to tab to each one and type over.
Here is a screen recording of the correct, tophatted behavior:

Screen.Recording.2026-03-24.at.1.54.33.PM.mov

What did you learn?

I learned about the block element █ .
in the context of the tests in the spec file, the block element is used by the test framework to mock the cursor position so the test knows when to trigger the autocomplete functionality and must be used when testing autocomplete behavior (which my change falls under) but isn't needed to test things like the dropdown labels being present or the documentation pop-up.

Before you deploy

  • I included a patch changeset
  • My feature is backward compatible

@FKauwe FKauwe self-assigned this Mar 27, 2026
@FKauwe FKauwe requested a review from a team as a code owner March 27, 2026 17:50
Copy link
Copy Markdown
Contributor

@aswamy aswamy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great stuff! Tophatted with 0, 1, and 2+ tabstops and everything works as expected. One small suggestion.

@FKauwe FKauwe force-pushed the add-tabstops-to-translations-variables branch from 451ab99 to f15566c Compare March 31, 2026 16:34
@FKauwe FKauwe merged commit 525fcac into main Mar 31, 2026
8 checks passed
@FKauwe FKauwe deleted the add-tabstops-to-translations-variables branch March 31, 2026 17:37
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.

Feature Request: Tab stops for translations

3 participants