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

Automatically close brackets and quotes #1801

Open
vkbo opened this issue Apr 6, 2024 · 4 comments
Open

Automatically close brackets and quotes #1801

vkbo opened this issue Apr 6, 2024 · 4 comments
Labels
editor Component: Editor enhancement Request: New feature or improvement planned Note: Feature planned for a later release

Comments

@vkbo
Copy link
Owner

vkbo commented Apr 6, 2024

Add an optional auto-feature to close brackets and quotes. Closing brackets and quotes should be separate settings since the user may want the former without the latter, depending on the writing style.

This is a common feature in code editors, and at least I am very used to it. I also noticed Obsidian added it recently.

@vkbo vkbo added enhancement Request: New feature or improvement editor Component: Editor planned Note: Feature planned for a later release labels Apr 6, 2024
@vkbo vkbo added this to the Release 2.5 Beta 1 milestone Apr 6, 2024
@tmarplatt
Copy link
Contributor

I.e. appending a closing quote next to the text cursor? If so, and without additional input (other than text), what happens when the user inserts a paragraph break?

Will the editor:

a. skip the quote symbol (leaving it as a closing paragraph character) and insert the break after?
b. insert the paragraph break as is, carrying the symbol over to the following paragraph?

In the latter case, then please consider allowing to auto-add a continuation quote symbol (as explained in #1770) on these particular circumstances. It would be an excellent feature to have.

@vkbo
Copy link
Owner Author

vkbo commented Apr 7, 2024

That would be an additional feature. It would need an extra field to specify this symbol, as the highlight rules related to #1770 are not going to be this specific.

This is a non-trivial thing to implement due to the need for full paragraph lookback. Currently, the editor only keeps a record of the last three characters. It doesn't actually know that you are inside a quote. So adding this feature may require too much processing. There is already a lot of code that is run every time you press a key, and Python is still a lot slower than C++.

Perhaps it could be a feature that only worked when auto-inserting closing quotes. I could set a flag when this mode is triggered and clear it when you leave the paragraph. So if it does this only as long as you keep typing without moving the cursor in other ways, I could probably make a lightweight implementation of it.

I haven't decided yet how to handle getting "out of" the auto-added closing symbol either. In code editors you either have to press the right arrow key, or type the closing symbol to skip past it. The latter sort of defeats the purpose, but it is what code editors tend to do. It's also what Obsidian does.

@tmarplatt
Copy link
Contributor

tmarplatt commented Apr 7, 2024

Some code editors allow you to tab out of an auto-closed section, provided you haven't done anything else than inserting code. The cursor either jumps to the next section, if there is one, or to the EOL. Also some editors allow you via hotkey to insert a new line (edit - from wherever your cursor is, and without carrying over any trailing code of the current line) and jump to the start of it, which is one way to skip typing a “purpose-defeating” section close symbol.

I'm not suggesting any of this, just throwing more known features out there. Perhaps a solution arises from it.

@vkbo
Copy link
Owner Author

vkbo commented Apr 8, 2024

Yeah, having to type the closing character defeats the purpose, and having to press the arrow key can be annoying, so I definitely would like to add some way to make it more useful.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
editor Component: Editor enhancement Request: New feature or improvement planned Note: Feature planned for a later release
Projects
None yet
Development

No branches or pull requests

2 participants