[occur] command cleanup
This commit is contained in:
parent
887aa24ceb
commit
2ba388ed04
3 changed files with 10 additions and 15 deletions
|
|
@ -34,26 +34,27 @@ var config = require("../config"),
|
|||
Occur = require("../occur").Occur;
|
||||
|
||||
// These commands can be installed in a normal command handler to start occur:
|
||||
exports.occurStartCommands = [{
|
||||
var occurStartCommands = [{
|
||||
name: "occur",
|
||||
exec: function(editor, options) {
|
||||
if (!options.needle) return;
|
||||
var handler = new OccurKeyboardHandler();
|
||||
editor.keyBinding.addKeyboardHandler(handler);
|
||||
editor.commands.addCommands(exports.occurCommands);
|
||||
editor.commands.addCommands(occurCommands);
|
||||
var occur = new Occur();
|
||||
occur.display(editor.session, options);
|
||||
},
|
||||
readOnly: true
|
||||
}];
|
||||
|
||||
exports.occurCommands = [{
|
||||
var occurCommands = [{
|
||||
name: "occurexit",
|
||||
bindKey: 'esc|Ctrl-G',
|
||||
exec: function(editor) {
|
||||
// if (!options.needle) return;
|
||||
var session = editor.session, occur = session.doc.$occur;
|
||||
if (occur) occur.displayOriginal(session);
|
||||
editor.commands.removeCommands(exports.occurCommands);
|
||||
editor.commands.removeCommands(occurCommands);
|
||||
var handler = editor.getKeyboardHandler();
|
||||
if (handler.isOccurHandler) editor.keyBinding.removeKeyboardHandler(handler);
|
||||
},
|
||||
|
|
@ -72,12 +73,11 @@ oop.inherits(OccurKeyboardHandler, HashHandler);
|
|||
this.isOccurHandler = true;
|
||||
|
||||
this.attach = function(editor) {
|
||||
HashHandler.call(this, exports.iSearchCommands, editor.commands.platform);
|
||||
HashHandler.call(this, occurCommands, editor.commands.platform);
|
||||
this.$editor = editor;
|
||||
}
|
||||
|
||||
this.detach = function(editor) {
|
||||
}
|
||||
this.detach = function() {}
|
||||
|
||||
var handleKeyboard$super = this.handleKeyboard;
|
||||
this.handleKeyboard = function(data, hashId, key, keyCode) {
|
||||
|
|
@ -87,7 +87,6 @@ oop.inherits(OccurKeyboardHandler, HashHandler);
|
|||
|
||||
}).call(OccurKeyboardHandler.prototype);
|
||||
|
||||
|
||||
exports.OccurKeyboardHandler = OccurKeyboardHandler;
|
||||
exports.commands = occurStartCommands;
|
||||
|
||||
});
|
||||
|
|
|
|||
|
|
@ -35,8 +35,6 @@ var oop = require("./lib/oop");
|
|||
var Range = require("./range").Range;
|
||||
var Search = require("./search").Search;
|
||||
var Document = require("./document").Document;
|
||||
var iSearchCommandModule = require("./commands/incremental_search_commands");
|
||||
var ISearchKbd = iSearchCommandModule.IncrementalSearchKeyboardHandler;
|
||||
|
||||
/**
|
||||
* @class Occur
|
||||
|
|
|
|||
|
|
@ -41,9 +41,7 @@ var MockRenderer = require("./test/mockrenderer").MockRenderer;
|
|||
var Range = require("./range").Range;
|
||||
var assert = require("./test/assertions");
|
||||
var Occur = require("./occur").Occur;
|
||||
var occurCommands = require("./commands/occur_commands");
|
||||
// var OccurKeyboardHandler = occurCommands.OccurKeyboardHandler;
|
||||
|
||||
var occurCommands = require("./commands/occur_commands").commands;
|
||||
var editor, occur, session;
|
||||
|
||||
module.exports = {
|
||||
|
|
@ -75,7 +73,7 @@ module.exports = {
|
|||
"test: occur command" : function() {
|
||||
var lines = ['hel', 'lo', '', 'wo', 'rld'];
|
||||
session.doc.insertLines(0, lines);
|
||||
editor.commands.addCommands(occurCommands.occurStartCommands);
|
||||
editor.commands.addCommands(occurCommands);
|
||||
editor.execCommand('occur', {needle: 'o'});
|
||||
assert.equal(session.getValue(), 'lo\nwo');
|
||||
assert.ok(editor.getKeyboardHandler().isOccurHandler, 'no occur handler installed');
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue