Skip to content

Support escaping snippet spaces#2223

Open
FireChickenProductivity wants to merge 54 commits into
talonhub:mainfrom
FireChickenProductivity:escape-spaces
Open

Support escaping snippet spaces#2223
FireChickenProductivity wants to merge 54 commits into
talonhub:mainfrom
FireChickenProductivity:escape-spaces

Conversation

@FireChickenProductivity

Copy link
Copy Markdown
Contributor

No description provided.

Comment thread core/snippets/snippets_parser.py Outdated
@FireChickenProductivity
FireChickenProductivity marked this pull request as ready for review July 11, 2026 00:11

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: d03ee74d1f

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread core/snippets/snippets_parser.py Outdated
@FireChickenProductivity
FireChickenProductivity marked this pull request as draft July 11, 2026 00:23
@FireChickenProductivity
FireChickenProductivity marked this pull request as ready for review July 11, 2026 02:22
Comment thread core/snippets/snippets_parser.py Outdated
return None

body = text[match_leading.start() :].rstrip()
body = rstrip_except_escaped_space(text[match_leading.start() :])

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Instead of my current special replacement of the rstrip, it might be better to just move the stripping logic to a better place.

@nriley nriley left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

From the community backlog session, things overall look good. A couple points:

  • I agree the escaping/stripping logic should be consolidated.
  • Consider displaying errors in snippets with notifications and not just logging them as many users do not tend to leave the Talon log open. @AndreasArvidsson does this sound OK if we were to change the behavior of the error function?

Comment thread core/snippets/README.md Outdated
Comment thread core/snippets/snippets_parser.py Outdated
@AndreasArvidsson

Copy link
Copy Markdown
Collaborator

From the community backlog session, things overall look good. A couple points:

* I agree the escaping/stripping logic should be consolidated.

* Consider displaying errors in snippets with notifications and not just logging them as many users do not tend to leave the Talon log open. @AndreasArvidsson does this sound OK if we were to change the behavior of the [error function](https://github.com/FireChickenProductivity/knausj_talon/blob/9eb9d01fe8c52158ec7c44bcfce0baeadba095ae/core/snippets/snippets_parser.py#L498)?

Sounds good

@FireChickenProductivity
FireChickenProductivity marked this pull request as draft July 18, 2026 01:48
@FireChickenProductivity
FireChickenProductivity marked this pull request as ready for review July 18, 2026 17:18

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 076211c1f1

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread core/snippets/snippets_parser.py Outdated
@FireChickenProductivity
FireChickenProductivity marked this pull request as draft July 18, 2026 17:54
@FireChickenProductivity
FireChickenProductivity marked this pull request as ready for review July 18, 2026 19:29

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 083b84ce5d

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread apps/vscode/vscode.py Outdated

def insert_snippet(body: str):
# Avoid triggering VSCode's escaping mechanisms on accident
body = body.replace("\\", "\\\\")

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Preserve existing dollar escapes when doubling slashes

When this VS Code override receives a snippet that already uses \$ to emit a literal dollar, doubling every backslash turns it into \\$, so VS Code parses an escaped backslash followed by a $exception variable instead of the literal $exception. This is already hit by the PHP catchStatement snippet (catch (\Throwable \$exception)) and by substitution text containing dollars, so inserting those snippets in VS Code produces the wrong text/placeholders; only escape literal backslashes without rewriting existing snippet escape sequences for $.

Useful? React with 👍 / 👎.

@FireChickenProductivity FireChickenProductivity Jul 18, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

We should try to handle escaping logic ourselves so that snippets work across editors. I can fix it so that VSCode handles escaped stops properly.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I reverted the change for now and will leave it to a followup.

@FireChickenProductivity
FireChickenProductivity marked this pull request as draft July 18, 2026 19:47
@FireChickenProductivity
FireChickenProductivity marked this pull request as ready for review July 18, 2026 20:16

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: ed01ece73f

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

# treat double backslash as escaped backslash
# treat backslash space as space
return (
body.replace("\\\\", UNICODE_ESCAPED_BACKSLASH_PLACEHOLDER)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Preserve placeholders after escaped backslashes

When a snippet needs a literal backslash immediately before a placeholder, e.g. a custom VS Code body \\$1 under the newly documented escaped-backslash syntax, this replacement collapses it to \$1. That final body is then passed to VS Code's snippet engine in apps/vscode/vscode.py:446; VS Code's grammar treats backslash before $ as escaping the dollar (https://code.visualstudio.com/docs/editing/userdefinedsnippets#_grammar), so $1 is inserted as literal text instead of becoming a tab stop. This is separate from the reverted VS Code override: the fresh evidence is the parser now emitting \$ from escaped literal backslashes before placeholders.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I do not plan on addressing VSCode specific issues in this PR without maintainer feedback.

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.

3 participants