From d2ec2c1208b5d145859f816e824de415b0e1ba1b Mon Sep 17 00:00:00 2001 From: anekos Date: Sun, 21 Sep 2008 12:30:42 +0000 Subject: 遅延によるバグを修正したような趣 git-svn-id: http://svn.coderepos.org/share/lang/javascript/vimperator-plugins/trunk@19679 d0d07461-0603-4401-acd4-de1884942a52 --- migemized_find.js | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'migemized_find.js') diff --git a/migemized_find.js b/migemized_find.js index c6e8e06..008afea 100644 --- a/migemized_find.js +++ b/migemized_find.js @@ -263,14 +263,17 @@ // 前のタイマーを削除するために保存しておく let delayCallTimer = null; + let delayedFunc = null; let migemized = { find: function find (str, backwards) { // 短時間に何回も検索をしないように遅延させる - let f = function () MF.findFirst(str, backwards); - if (delayCallTimer) + delayedFunc = function () MF.findFirst(str, backwards); + if (delayCallTimer) { + delayCallTimer = null; clearTimeout(delayCallTimer); - delayCallTimer = setTimeout(function () f(), 300); + } + delayCallTimer = setTimeout(function () delayedFunc(), 300); }, findAgain: function findAgain (reverse) { @@ -279,6 +282,11 @@ }, searchSubmitted: function searchSubmitted (command, forcedBackward) { + if (delayCallTimer) { + delayCallTimer = null; + clearTimeout(delayCallTimer); + delayedFunc(); + } if (!MF.submit()) liberator.echoerr('not found: ' + MF.currentSearchText); }, -- cgit v1.2.3