@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.
In src/editor.c:
> + 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.
In src/editor.h:
> @@ -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
In src/editor.c:
> + 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 """
In doc/geany.txt:
> @@ -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, view it on GitHub, or unsubscribe.
Triage notifications on the go with GitHub Mobile for iOS or Android.