don't sélect on unfold

This commit is contained in:
Fabian Jakobs 2011-12-14 13:28:02 +01:00
commit 653a88ff30
3 changed files with 12 additions and 18 deletions

View file

@ -358,8 +358,8 @@ function Folding() {
var startRow = foldLine.start.row;
var endRow = foldLine.end.row;
var foldLines = this.$foldData,
folds = foldLine.folds;
var foldLines = this.$foldData;
var folds = foldLine.folds;
// Simple case where there is only one fold in the FoldLine such that
// the entire fold line can get removed directly.
if (folds.length == 1) {

View file

@ -94,20 +94,12 @@ function DefaultHandlers(editor) {
if (selectionEmpty) {
editor.moveCursorToPosition(pos);
}
if(button == 2) {
if (button == 2) {
editor.textInput.onContextMenu({x: ev.clientX, y: ev.clientY}, selectionEmpty);
event.capture(editor.container, function(){}, editor.textInput.onContextMenuClose);
}
return;
}
else {
// Select the fold as the user clicks it.
var fold = editor.session.getFoldAt(pos.row, pos.column, 1);
if (fold) {
editor.selection.setSelectionRange(fold.range);
return;
}
}
if (!inSelection) {
// Directly pick STATE_SELECT, since the user is not clicking inside

View file

@ -40,18 +40,20 @@
define(function(require, exports, module) {
function FoldHandler(editor) {
editor.on("click", function(ev) {
var pos = ev.getDocumentPosition();
editor.on("click", function(event) {
var position = event.getDocumentPosition();
var session = editor.session;
// If the user dclicked on a fold, then expand it.
var fold = editor.session.getFoldAt(pos.row, pos.column, 1);
var fold = session.getFoldAt(position.row, position.column, 1);
if (fold) {
if (ev.getAccelKey())
editor.session.removeFold(fold);
if (event.getAccelKey())
session.removeFold(fold);
else
editor.session.expandFold(fold);
session.expandFold(fold);
ev.preventDefault();
event.preventDefault();
}
});
}