Don't switch to normal mode in load committed (#95).
authorDaniel Carl <danielcarl@gmx.de>
Fri, 1 Aug 2014 12:10:03 +0000 (14:10 +0200)
committerDaniel Carl <danielcarl@gmx.de>
Fri, 1 Aug 2014 12:10:03 +0000 (14:10 +0200)
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.

src/main.c

index 481244c..3112cf4 100644 (file)
@@ -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: