aboutsummaryrefslogtreecommitdiffstats
path: root/migemized_find.js
diff options
context:
space:
mode:
authoranekos2011-08-16 13:48:19 +0900
committeranekos2011-08-16 13:48:19 +0900
commit2432aa0649ae9d1dbf5a110c21a3556e561ddb1b (patch)
tree5d1f468c2363e97b70f3200a7eec51991df924ac /migemized_find.js
parentc5551394f1a415a1f6fcfbb944b6467a8d7cb3cc (diff)
downloadvimperator-plugins-2432aa0649ae9d1dbf5a110c21a3556e561ddb1b.tar.bz2
検索履歴を無理やり追加
Diffstat (limited to 'migemized_find.js')
-rw-r--r--migemized_find.js26
1 files changed, 25 insertions, 1 deletions
diff --git a/migemized_find.js b/migemized_find.js
index f6f9f4b..2d11f00 100644
--- a/migemized_find.js
+++ b/migemized_find.js
@@ -39,7 +39,7 @@ let PLUGIN_INFO =
<name lang="ja">Migemized Find</name>
<description>Migemize default page search.</description>
<description lang="ja">デフォルトのドキュメント内検索をミゲマイズする。</description>
- <version>2.10.2</version>
+ <version>2.11.0</version>
<author mail="anekos@snca.net" homepage="http://d.hatena.ne.jp/nokturnalmortum/">anekos</author>
<license>new BSD License (Please read the source code comments of this plugin)</license>
<license lang="ja">修正BSDライセンス (ソースコードのコメントを参照してください)</license>
@@ -265,6 +265,9 @@ let PLUGIN_INFO =
MODE_REGEXP: 1,
MODE_MIGEMO: 2,
+ // 検索履歴
+ history: [],
+
// 全体で共有する変数
lastSearchText: null,
lastSearchExpr: null,
@@ -493,6 +496,17 @@ let PLUGIN_INFO =
},
submit: function () {
+ let exists = false, newHistory = [];
+ for (let [i, h] in Iterator(this.history)) {
+ if (h === this.currentSearchText) {
+ exists = true;
+ } else {
+ newHistory.push(h);
+ }
+ }
+ newHistory.push(this.currentSearchText);
+ this.history = newHistory;
+
this.lastSearchText = this.currentSearchText;
this.lastSearchExpr = this.currentSearchExpr;
this.lastColor = this.currentColor;
@@ -569,6 +583,8 @@ let PLUGIN_INFO =
clearTimeout(delayCallTimer);
delayedFunc();
}
+ if (MF.currentSearchText !== command)
+ MF.findFirst(command, forcedBackward);
if (!MF.submit())
liberator.echoerr('not found: ' + MF.currentSearchText);
},
@@ -583,6 +599,13 @@ let PLUGIN_INFO =
} else if (str === false)
MF.findAgain();
},
+
+ completer: function (context, args) {
+ context.completions = [
+ [v, v]
+ for ([, v] in Iterator(MF.history))
+ ];
+ }
};
finder.findAgain = migemized.findAgain;
@@ -595,6 +618,7 @@ let PLUGIN_INFO =
plugins.libly.$U.around(commandline._input, 'change', function (next, [str]) migemized.onChange(str));
plugins.libly.$U.around(commandline._input, 'submit', function (next, [str]) migemized.onSubmit(str));
plugins.libly.$U.around(commandline._input, 'cancel', function (next, [str]) migemized.onCancel());
+ commandline._input.complete = migemized.completer;
return res;
},
true