Skip to content

Implement bracket pairing and handling for user input#63

Open
ShingZhanho wants to merge 4 commits into
akshayravikumar:masterfrom
ShingZhanho:master
Open

Implement bracket pairing and handling for user input#63
ShingZhanho wants to merge 4 commits into
akshayravikumar:masterfrom
ShingZhanho:master

Conversation

@ShingZhanho

@ShingZhanho ShingZhanho commented May 6, 2026

Copy link
Copy Markdown

This pull request implements auto-completion features for LaTeX input in the game.
All auto-completions apply to the #user-input textarea in the game.
Below is a summary of the implemented features, with examples of the auto-completion behavior.

Bracket pair auto-close

Typed Result Cursor
( () between
[ [] between
{ {} between
  • Selection wrap: with text selected, typing (, [, or { wraps the selection in the pair.
  • Skip-over: typing ), ], or } when that character is already immediately after the cursor moves the cursor past it instead of inserting a duplicate.
  • Paired backspace: pressing Backspace between a matched pair deletes both brackets.

\left/\right delimiter pairs

Typed Result Cursor
\left( \left(\right) between
\left[ \left[\right] between
\left{ \left{\right} between
\left\{ \left\{\right\} between
\left| \left|\right| between
\left\| \left\|\right\| between
\left< \left<\right> between

Escaped bracket pairs

Typed Result Cursor
\{ \{\} between
\| \|\| between

| alone does not trigger auto-completion.


Named delimiter pairs

Typed Result Cursor
\langle \langle\rangle between
\left\langle \left\langle\right\rangle between
\lfloor \lfloor\rfloor between
\left\lfloor \left\lfloor\right\rfloor between
\lceil \lceil\rceil between
\left\lceil \left\lceil\right\rceil between
\lvert \lvert\rvert between
\left\lvert \left\lvert\right\rvert between
\lVert \lVert\rVert between
\left\lVert \left\lVert\right\rVert between

\langle completion is incremental: \lang first inserts \lang\rang, then completing to \langle automatically upgrades the closing tag to \rangle (or \right\rangle when preceded by \left\).


Environment auto-close

Typed Result Cursor
\begin{align} \begin{align}\end{align} between
  • { after \begin is not auto-closed — the user types the environment name freely and closes with }.
  • Typing } to close \begin{envname triggers the completion: inserts }\end{envname} and places the cursor between the \begin and \end blocks.

Navigation

Key Action
Tab Jumps cursor past the next } in the text. If the cursor is immediately before \end{...}, jumps past the entire \end{envname} tag instead.

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.

1 participant