[Github-comments] [geany/geany] Improve auto close (#2943)
Thomas Martitz
notifications at xxxxx
Fri Oct 15 22:49:28 UTC 2021
@kugel- commented on this pull request.
I still need to check the second commit in more detail.
I think it may be useful to compare your work with what the autoclose plugin already does. Perhaps it gives some insights w.r.t to the implementation.
> + isAutoClosed = TRUE;
+ break;
+ case '\'':
+ if (editor_prefs.autoclose_chars & GEANY_AC_SQUOTE)
+ isAutoClosed = TRUE;
+ break;
+ case '"':
+ if (editor_prefs.autoclose_chars & GEANY_AC_DQUOTE)
+ isAutoClosed = TRUE;
+ break;
+ }
+
+ gchar cNext = sci_get_char_at( sci, pos);
+
+ if( isAutoClosed && cNext == c ) {
+ sci_delete_range(sci, pos, 1);
Instead of truly deleting the closing char don't you think it would be better to just replace the insertion by a "virtual" cursor movement? Might make a difference w.r.t. undo behavior.
> @@ -138,6 +138,7 @@ typedef struct GeanyEditorPrefs
gint autocompletion_update_freq;
gint scroll_lines_around_cursor;
gint ime_interaction; /* input method editor's candidate window behaviour */
+ guint autoclose_chars_consume;
unecessary
> + if (editor_prefs.autoclose_chars & GEANY_AC_PARENTHESIS)
+ isAutoClosed = TRUE;
+ break;
+ case '}':
+ if (editor_prefs.autoclose_chars & GEANY_AC_CBRACKET)
+ isAutoClosed = TRUE;
+ break;
+ case ']':
+ if (editor_prefs.autoclose_chars & GEANY_AC_SBRACKET)
+ isAutoClosed = TRUE;
+ break;
+ case '\'':
+ if (editor_prefs.autoclose_chars & GEANY_AC_SQUOTE)
+ isAutoClosed = TRUE;
+ break;
+ case '"':
I wonder how Python multiline strings behave with this change? These ones enclosed by 3 quotoes `""" foo bar """`
> @@ -2193,6 +2193,10 @@ Geany can automatically insert a closing bracket and quote characters when
you open them. For instance, you type a ``(`` and Geany will automatically
insert ``)``. With the following options, you can define for which
characters this should work.
+For a more flowing writing (not move the typing hand to arrow keys) Geany
+checks if the character written is the closing quote or bracket that was
+previously inserted. In that case only one quote or bracket of the one written
+and the one previously inserted remains.
This can be written in a much more concise way. E.g. "To prevent extraneous quotes or brackets Geany detects if you manually insert closing characters.". Then I would place that before the "With the following options, you …" sentence.
--
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/geany/geany/pull/2943#pullrequestreview-781245783
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.geany.org/pipermail/github-comments/attachments/20211015/fee8c71d/attachment-0001.htm>
More information about the Github-comments
mailing list