Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Typing exactly 3 backticks is inconvenient because of automatic pairing. #591

Open
matj1 opened this issue Apr 1, 2025 · 6 comments
Open
Labels
bug Something isn't working.

Comments

@matj1
Copy link

matj1 commented Apr 1, 2025

Description

I can't easily write exactly 3 backticks because of automatic pairing of delimiters. That is annoying when I want to turn something into a block of raw text.

When I type a backtick the first time, it inserts also a second one after the caret like this:

`|`

When I type a backtick the second time, it does not add any backtick and skips the second one because I type the closing delimiter. So it ends up so:

``|

After that, typing additional backticks repeats the process adding backticks in pairs and skipping the second one of the last pair.
So the best way to insert exactly 3 backticks is to insert 4 backticks and delete the last one.

I expect that typing exactly 3 (or fewer) backticks would insert exactly 3 backticks. A possible solution is that, if there are two backticks before the caret, typing a backtick would insert only one caret. An other possible solution is that automatic pairing of delimiters would be disabled between backticks (in raw text), so typing 2 backticks would result in 2 backticks before the caret and one after it like ``|`.

Reproduction URL

No response

Browsers

Firefox, Chrome

OS

Linux

@matj1 matj1 added the bug Something isn't working. label Apr 1, 2025
@laurmaedje
Copy link
Member

This is interesting because it's quite different with a German keyboard (on macOS). There is no auto-closing at all because the backtick is a dead key.

@frozolotl
Copy link

frozolotl commented Apr 1, 2025

It seems I didn't read the issue well enough.

Original comment This issue can't reasonably be solved by the Typst web app because it is actually a feature of your keyboard layout called "[dead keys](https://en.wikipedia.org/wiki/Dead_key)." Overwriting the behavior would cause numerous issues and confusion.

I would suggest changing your keyboard layout to a variant without those dead keys. Under Linux-based systems you can do this by setting the "nodeadkeys" option.
You can do the same on Windows and macOS, though it is a bit more difficult to turn off from what I remember.

Operating System BehaviorI'm also not totally sure if it's even much of an issue on Linux and macOS because I think there the backticks are only inserted once when pressing the key twice, instead of two backticks appearing at once when pressing the key twice on Windows.

If you want to keep your keyboard layout as it is, there is an easy solution though: just type six backticks and move your cursor to the middle.
Alternatively, you can just use four backticks instead of three on both sides. This is valid Typst syntax.

@matj1
Copy link
Author

matj1 commented Apr 1, 2025

@frozolotl, it seems that you are wrong because I type a backtick by pressing a single key once, and laurmaedje wrote that, if backtick is a dead key, there is no autoclosing of backticks. So it seems that the issue is of the web app and not of dead keys.

Edit: I can type a backtick also by a dead key for characters with a grave accent, and I can confirm the behavior described by laurmaedje. Typing the dead key twice or the dead key and a space always inserts exactly one backtick. But that is still inconvenient.

@Andrew15-5
Copy link

Andrew15-5 commented Apr 3, 2025

The perfect behavior is actually after pressing the backtick the third time is to do

```|```

This is what my NvChad config for Neovim does by default in Markdown, which is super useful, especially since I write a lot of issues/posts with code blocks via GhostText. So I would write 6 chars

```typ

And then press Enter and I'm already in the block code

```typ
|
```

Which I guess ideally requires IDE to auto-add a new line after the cursor so that it does not end up like this:

```typ
|```

My config is a mess because of NvChad 2.0 and the added to Typst files behavior is random, which is insane, so I will have to revisit this some other time. I still mostly only use this in Markdown anyway.

@matj1
Copy link
Author

matj1 commented Apr 3, 2025

What @Andrew15-5 describes is good behavior, but I would rather insert exactly 3 backticks, because I often paste in some code and put 3 backticks before that and 3 backticks after that. But my workflow could be adjusted to work with what Andrew15-5 describes, so I would insert backticks first and pasted the code in between them.

@laurmaedje
Copy link
Member

I agree that the described behaviour would be ideal. We'll have to see whether we can implement that. Will be a bit tricky to test as well with all the differing behaviour across keyboard layouts.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working.
Projects
None yet
Development

No branches or pull requests

4 participants