[gnome-builder] python-indenter: handle compose keys with e or f
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder] python-indenter: handle compose keys with e or f
- Date: Thu, 28 Sep 2017 21:15:05 +0000 (UTC)
commit 93ba86d3bde7d4bd01541c24ef2ec889abf95add
Author: Christian Hergert <chergert redhat com>
Date: Thu Sep 28 14:14:49 2017 -0700
python-indenter: handle compose keys with e or f
We hijack the e and f keys to unindent on else or elif. We need to be sure
that is what was inserted or we mistakingly indent space after the char.
https://bugzilla.gnome.org/show_bug.cgi?id=788277
src/plugins/python-pack/ide-python-indenter.c | 22 +++++++++++++++++-----
1 files changed, 17 insertions(+), 5 deletions(-)
---
diff --git a/src/plugins/python-pack/ide-python-indenter.c b/src/plugins/python-pack/ide-python-indenter.c
index ebbd927..751eaac 100644
--- a/src/plugins/python-pack/ide-python-indenter.c
+++ b/src/plugins/python-pack/ide-python-indenter.c
@@ -662,13 +662,25 @@ ide_python_indenter_format (IdeIndenter *indenter,
gunichar ch;
gint line;
- /* possibly trying to adjust "else" or "elif". we always return in this
- * block, since we don't want to process anything else.
- */
+ /* Figure out the inserted character */
gtk_text_iter_backward_char (&iter);
ch = gtk_text_iter_get_char (&iter);
- if (ch == 'e' || ch == 'f')
- return maybe_unindent_else_or_elif (python, text_view, begin, end);
+
+ /*
+ * If we triggered from 'e' or 'f', but that is not what was inserted,
+ * short-circuit now. (Such as from é compose keys, etc).
+ */
+ if (event->keyval == GDK_KEY_e || event->keyval == GDK_KEY_f)
+ {
+ if (ch != 'e' && ch != 'f')
+ return NULL;
+
+ /*
+ * Possibly trying to adjust "else" or "elif". we always return in this
+ * block, since we don't want to process anything else.
+ */
+ return maybe_unindent_else_or_elif (python, text_view, begin, end);
+ }
iter = *begin;
line = gtk_text_iter_get_line (&iter);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]