[gnome-builder/gnome-builder-3-26] python-indenter: handle compose keys with e or f



commit c521ab946fe3cfedf389cc80527686dec8026d25
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

 plugins/python-pack/ide-python-indenter.c |   22 +++++++++++++++++-----
 1 files changed, 17 insertions(+), 5 deletions(-)
---
diff --git a/plugins/python-pack/ide-python-indenter.c b/plugins/python-pack/ide-python-indenter.c
index ebbd927..751eaac 100644
--- a/plugins/python-pack/ide-python-indenter.c
+++ b/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]