focus-editor / focus

A simple and fast text editor
GNU General Public License v3.0
1.81k stars 99 forks source link

Feature request: auto surround quotes #444

Open Kuroonehalf opened 1 month ago

Kuroonehalf commented 1 month ago

Unsure if the default behavior in other editors applies to single tick quotes, since it could interfere with apostrophes in strings, but I figure this should be easy enough to add for double tick quotes. I write game scripts in a python language so I use quotes constantly, and quote auto surround is a nice QOL feature.

focus-editor commented 1 month ago

How is this different from the existing auto surround feature, please clarify

On Sat, Oct 12, 2024, 2:09 PM Kuro @.***> wrote:

Unsure if the default behavior in other editors applies to single tick quotes, since it could interfere with apostrophes in strings, but I figure this should be easy enough to add for double tick quotes. I write game scripts in a python language so I use quotes constantly, and quote auto surround is a nice QOL feature.

— Reply to this email directly, view it on GitHub https://github.com/focus-editor/focus/issues/444, or unsubscribe https://github.com/notifications/unsubscribe-auth/A4OX77REO7GJ7MZW67YPFCLZ3BZDRAVCNFSM6AAAAABPZ4FDEWVHI2DSMVQWIX3LMV43ASLTON2WKOZSGU4DEMZYGY4DEMA . You are receiving this because you are subscribed to this thread.Message ID: @.***>

Kuroonehalf commented 1 month ago

I assume you mean the auto_surround_with_brackets_and_quotes option. Even with it toggled on, I don't seem to get any quote auto surround. Is it supposed to work?

focus-editor commented 1 month ago

It should auto-surround any selection when you type a quote char.

On Sat, Oct 12, 2024, 5:35 PM Kuro @.***> wrote:

I assume you mean the auto_surround_with_brackets_and_quotes option. Even with it toggled on, I don't seem to get any quote auto surround. Is it supposed to work?

— Reply to this email directly, view it on GitHub https://github.com/focus-editor/focus/issues/444#issuecomment-2408378094, or unsubscribe https://github.com/notifications/unsubscribe-auth/A4OX77QBH7YQNSPAD3O3FNTZ3CRI7AVCNFSM6AAAAABPZ4FDEWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDIMBYGM3TQMBZGQ . You are receiving this because you commented.Message ID: @.***>

Kuroonehalf commented 1 month ago

Oh, I understand now. You make a selection, then press quote. I mean I'd like it to work without selection, the way auto surround brackets/braces work. You open quote, and it automatically places another quote in front of the cursor.

focus-editor commented 1 month ago

You mean you type a quote and it types another quote?

On Sun, Oct 13, 2024, 1:37 AM Kuro @.***> wrote:

Oh, I understand now. You make a selection, then press quote. I mean I'd like it to work without selection, the way auto surround brackets/braces work.

— Reply to this email directly, view it on GitHub https://github.com/focus-editor/focus/issues/444#issuecomment-2408549895, or unsubscribe https://github.com/notifications/unsubscribe-auth/A4OX77UNXEBLOEWNYVOWAG3Z3EJZRAVCNFSM6AAAAABPZ4FDEWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDIMBYGU2DSOBZGU . You are receiving this because you commented.Message ID: @.***>

Kuroonehalf commented 1 month ago

Right. Types another quote, 1 character ahead of the cursor. The basic implemention of this seems like it might be that simple.

A more fancy implementation might want to detect when the quote is opening or closing a string, and if it's closing, don't type the extra quote. It should also account for deleting an empty quote string (i.e. [quote][cursor][quote]), which ideally should delete both quotes.

I forgot to mention, but this feature is also nice so that when you're typing a string, it doesn't interpret it as code and syntax highlight it incorrectly.

focus-editor commented 1 month ago

While this feature is something some people will definitely find useful, I believe it crosses the line between usefulness and annoyingly staying in your way. It wasn't implemented deliberately. The solution is to type two quotes and then press back (2 keystrokes), and this way you're in control in 100% of the cases, whereas with that feature there will always be situations where it types a quote you didn't want. We don't want this even for an opt-in feature.

On Sun, Oct 13, 2024, 8:35 AM Kuro @.***> wrote:

Right. Types another quote, 1 character ahead of the cursor. The basic implemention of this seems like it might be that simple.

A more fancy implementation might want to detect when the quote is opening or closing a string, and if it's closing, don't type the extra quote. It should also account for deleting an empty quote string (i.e. [quote][cursor][quote]), which ideally should delete both quotes.

I forgot to mention, but this feature is also nice so that when you're typing a string, it doesn't interpret it as code and syntax highlight it incorrectly.

— Reply to this email directly, view it on GitHub https://github.com/focus-editor/focus/issues/444#issuecomment-2408675463, or unsubscribe https://github.com/notifications/unsubscribe-auth/A4OX77R3QRV5XQBXHQ2WGETZ3F2WLAVCNFSM6AAAAABPZ4FDEWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDIMBYGY3TKNBWGM . You are receiving this because you commented.Message ID: @.***>

Kuroonehalf commented 1 month ago

I'm not sure I understand this possible annoying scenario. When would the added quote get in the way? Generally, all quotes opened must be closed, no? You open it, type whatever you want to type, then press right to go to the right of the closing quote. Unless you're single tick quoting a double tick quote, but that strikes me as an exceedingly rare scenario. On the other hand, any random game script will have thousands of lines in quotes, and a little QOL feature like this would go a long way. I guess if you're really opposed I'll drop my case, but it's a feature that would be useful to many.

focus-editor commented 1 month ago

Typing 3 quotes for a docstring in python. Typing an opening quote on one line and a closing quote on another line. Deleting a quote in the middle of other quotes. Using multiple cursors to type quotes, some of which might have a quote already next to them.

These are things which have personally annoyed me in the past that came to mind.

Focus is about always being fully in control of what appears on screen, and with this feature it's hard to impossible to get every case right, so we choose not to implement it at all.

You could bring it up on discord to gauge public support for this feature. If everyone overwhelmingly wants it we might reconsider.

On Sun, Oct 13, 2024, 4:05 PM Kuro @.***> wrote:

I'm not sure I understand this possible annoying scenario. When would the added quote get in the way? Generally, all quotes opened must be closed, no? You open it, type whatever you want to type, then press right to go to the right of the closing quote. Unless you're single tick quoting a double tick quote, but that strikes me as an exceedingly rare scenario. On the other hand, any random game script will have thousands of lines in quotes, and a little QOL feature like this would go a long way. I guess if you're really opposed I'll drop my case, but it's a feature that would be useful to many.

— Reply to this email directly, view it on GitHub https://github.com/focus-editor/focus/issues/444#issuecomment-2408799041, or unsubscribe https://github.com/notifications/unsubscribe-auth/A4OX77QY3TS3MJXIKA42VMTZ3HPORAVCNFSM6AAAAABPZ4FDEWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDIMBYG44TSMBUGE . You are receiving this because you commented.Message ID: @.***>