parent
9a4a387de6
commit
76adcc51a0
2 changed files with 0 additions and 107 deletions
|
|
@ -402,18 +402,6 @@ exports.commands = [{
|
||||||
exec: function(editor) { editor.jumpToMatching(true); },
|
exec: function(editor) { editor.jumpToMatching(true); },
|
||||||
multiSelectAction: "forEach",
|
multiSelectAction: "forEach",
|
||||||
readOnly: true
|
readOnly: true
|
||||||
}, {
|
|
||||||
name: "jumptomatchingtag",
|
|
||||||
bindKey: bindKey("Alt-P", "Alt-Shift-P"),
|
|
||||||
exec: function(editor) { editor.jumpToMatchingTag(); },
|
|
||||||
multiSelectAction: "forEach",
|
|
||||||
readOnly: true
|
|
||||||
}, {
|
|
||||||
name: "selecttomatchingtag",
|
|
||||||
bindKey: bindKey("Alt-Shift-P", null),
|
|
||||||
exec: function(editor) { editor.jumpToMatchingTag(true); },
|
|
||||||
multiSelectAction: "forEach",
|
|
||||||
readOnly: true
|
|
||||||
},
|
},
|
||||||
|
|
||||||
// commands disabled in readOnly mode
|
// commands disabled in readOnly mode
|
||||||
|
|
|
||||||
|
|
@ -48,7 +48,6 @@ var EventEmitter = require("./lib/event_emitter").EventEmitter;
|
||||||
var CommandManager = require("./commands/command_manager").CommandManager;
|
var CommandManager = require("./commands/command_manager").CommandManager;
|
||||||
var defaultCommands = require("./commands/default_commands").commands;
|
var defaultCommands = require("./commands/default_commands").commands;
|
||||||
var config = require("./config");
|
var config = require("./config");
|
||||||
var TokenIterator = require("./token_iterator").TokenIterator;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The main entry point into the Ace functionality.
|
* The main entry point into the Ace functionality.
|
||||||
|
|
@ -1949,100 +1948,6 @@ var Editor = function(renderer, session) {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
|
||||||
* Moves the cursor's row and column to the next matching tag.
|
|
||||||
*
|
|
||||||
**/
|
|
||||||
this.jumpToMatchingTag = function(select) {
|
|
||||||
var tag;
|
|
||||||
var depth = {};
|
|
||||||
var sel = {};
|
|
||||||
var cursor = this.getCursorPosition();
|
|
||||||
var iterator = new TokenIterator(this.session, cursor.row, cursor.column);
|
|
||||||
var prevToken = iterator.getCurrentToken();
|
|
||||||
var token = iterator.stepForward();
|
|
||||||
|
|
||||||
//get next closing tag
|
|
||||||
if (!token || token.type.indexOf('tag-name') === -1) {
|
|
||||||
do {
|
|
||||||
prevToken = token;
|
|
||||||
token = iterator.stepForward();
|
|
||||||
|
|
||||||
if(token && token.type.indexOf('tag-name') !== -1) {
|
|
||||||
if (isNaN(depth[token.value])) {
|
|
||||||
depth[token.value] = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (prevToken.value==='<' ){
|
|
||||||
depth[token.value]++;
|
|
||||||
} else if ( prevToken.value==='</') {
|
|
||||||
depth[token.value]--;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} while (token && (isNaN(depth[token.value]) || depth[token.value]>=0));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (token && token.type.indexOf('tag-name') !== -1) {
|
|
||||||
sel.end = {
|
|
||||||
column: iterator.getCurrentTokenColumn()-2,
|
|
||||||
row: iterator.getCurrentTokenRow()
|
|
||||||
};
|
|
||||||
tag = token.value;
|
|
||||||
}
|
|
||||||
|
|
||||||
//no tag found
|
|
||||||
if (!tag) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
//find matching tag
|
|
||||||
do {
|
|
||||||
token = prevToken;
|
|
||||||
prevToken = iterator.stepBackward();
|
|
||||||
|
|
||||||
if( prevToken ){
|
|
||||||
if (prevToken.type.indexOf('tag-close') !== -1) {
|
|
||||||
sel.start = {
|
|
||||||
column: iterator.getCurrentTokenColumn()+1,
|
|
||||||
row: iterator.getCurrentTokenRow()
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
if (token.value===tag && token.type.indexOf('tag-name') !== -1 && prevToken.value==='<') {
|
|
||||||
depth[tag]++;
|
|
||||||
} else if ( token.value===tag && token.type.indexOf('tag-name') !== -1 && prevToken.value==='</') {
|
|
||||||
depth[tag]--;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} while (prevToken && (token.type.indexOf('tag-name') === -1 || depth[tag] !== 0));
|
|
||||||
|
|
||||||
//we found it
|
|
||||||
if (token && token.type.indexOf('tag-name')) {
|
|
||||||
var range = new Range(
|
|
||||||
sel.start.row,
|
|
||||||
sel.start.column,
|
|
||||||
sel.end.row,
|
|
||||||
sel.end.column
|
|
||||||
);
|
|
||||||
|
|
||||||
var pos = range.start;
|
|
||||||
if (pos.row == cursor.row && Math.abs(pos.column - cursor.column) < 2)
|
|
||||||
pos = range.end;
|
|
||||||
|
|
||||||
pos = range && range.cursor || pos;
|
|
||||||
if (pos) {
|
|
||||||
if (select) {
|
|
||||||
if (range && range.isEqual(this.getSelectionRange()))
|
|
||||||
this.clearSelection();
|
|
||||||
else
|
|
||||||
this.selection.selectTo(pos.row, pos.column);
|
|
||||||
} else {
|
|
||||||
this.selection.moveTo(pos.row, pos.column);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Moves the cursor to the specified line number, and also into the indiciated column.
|
* Moves the cursor to the specified line number, and also into the indiciated column.
|
||||||
* @param {Number} lineNumber The line number to go to
|
* @param {Number} lineNumber The line number to go to
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue