From 2432aa0649ae9d1dbf5a110c21a3556e561ddb1b Mon Sep 17 00:00:00 2001
From: anekos
Date: Tue, 16 Aug 2011 13:48:19 +0900
Subject: 検索履歴を無理やり追加
---
migemized_find.js | 26 +++++++++++++++++++++++++-
1 file changed, 25 insertions(+), 1 deletion(-)
(limited to 'migemized_find.js')
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 =
Migemized Find
Migemize default page search.
デフォルトのドキュメント内検索をミゲマイズする。
- 2.10.2
+ 2.11.0
anekos
new BSD License (Please read the source code comments of this plugin)
修正BSDライセンス (ソースコードのコメントを参照してください)
@@ -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
--
cgit v1.2.3