From 469acff29be41e60eb8e1c24f007d435711d2b50 Mon Sep 17 00:00:00 2001 From: Jez Ng Date: Thu, 19 Jan 2012 01:09:41 +0800 Subject: Exit implicit insert mode only upon tab switch. Don't do it when the user has merely switched windows. --- background_page.html | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'background_page.html') diff --git a/background_page.html b/background_page.html index b8516f1b..814c0687 100644 --- a/background_page.html +++ b/background_page.html @@ -18,6 +18,7 @@ var singleKeyCommands = []; var focusedFrame = null; var framesForTab = {}; + var lastActiveTabIds = {}; // Keys are either literal characters, or "named" - for example (alt+b), (left arrow) or // This regular expression captures two groups: the first is a named key, the second is the remainder of @@ -307,6 +308,10 @@ chrome.tabs.onSelectionChanged.addListener(function(tabId, selectionInfo) { if (selectionChangedHandlers.length > 0) { selectionChangedHandlers.pop().call(); } + + if (lastActiveTabIds[selectionInfo.windowId] !== undefined) + chrome.tabs.sendRequest(lastActiveTabIds[selectionInfo.windowId], { name: "exitImplicitInsertMode" }); + lastActiveTabIds[selectionInfo.windowId] = tabId; }); function repeatFunction(func, totalCount, currentCount, frameId) { @@ -428,6 +433,7 @@ chrome.windows.onRemoved.addListener(function(windowId) { delete tabQueue[windowId]; + delete lastActiveTabIds[windowId]; }); function restoreTab(callback) { -- cgit v1.2.3