From: Daniel Carl <danielcarl@gmx.de>
Date: Fri, 1 Aug 2014 12:10:03 +0000 (+0200)
Subject: Don't switch to normal mode in load committed (#95).
X-Git-Url: https://git.owens.tech/about.html/about.html/git?a=commitdiff_plain;h=60baf0abd58138d26d8397cec4091b4ade7b5959;p=vimb.git

Don't switch to normal mode in load committed (#95).

On pages like translate.google.com where JavaScript changes the location hash
of the page, webkit performs nearly a new load of the page. This caused vimb
to switch from input to normal mode like intended if a form is submitted out
of input mode.

If only the location hash of a loaded page is changed, the used load-status
are WEBKIT_LOAD_COMMITTED and WEBKIT_LOAD_FIRST_VISUALLY_NON_EMPTY_LAYOUT. So
we can't switch to normal mode in load committed.
---

diff --git a/src/main.c b/src/main.c
index 481244c..3112cf4 100644
--- a/src/main.c
+++ b/src/main.c
@@ -529,11 +529,6 @@ static void webview_load_status_cb(WebKitWebView *view, GParamSpec *pspec)
                 js_eval_file(ctx, vb.files[FILES_SCRIPT]);
             }
 
-            /* if we load a page from a submitted form, leave the insert mode */
-            if (vb.mode->id == 'i') {
-                mode_enter('n');
-            }
-
             vb_update_statusbar();
             vb_update_urlbar(uri);
             /* save the current URI in register % */
@@ -544,6 +539,10 @@ static void webview_load_status_cb(WebKitWebView *view, GParamSpec *pspec)
             break;
 
         case WEBKIT_LOAD_FIRST_VISUALLY_NON_EMPTY_LAYOUT:
+            /* if we load a page from a submitted form, leave the insert mode */
+            if (vb.mode->id == 'i') {
+                mode_enter('n');
+            }
             break;
 
         case WEBKIT_LOAD_FINISHED: