Skip to content

Commit

Permalink
Revert "2199: regression - matching parentheses not deleted"
Browse files Browse the repository at this point in the history
Using behaviors doesn't work right because we can no longer distinguish between deleting left (backspace) and deleting right (delete); we only want to do the special logic for the former case.

This reverts commit c894905.
  • Loading branch information
jcheng5 committed Jan 4, 2012
1 parent c894905 commit 8210ac8
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 44 deletions.
74 changes: 34 additions & 40 deletions src/gwt/acesupport/acemode/auto_brace_insert.js
Expand Up @@ -123,6 +123,40 @@ define("mode/auto_brace_insert", function(require, exports, module)
token.column === pos.column-1;
};

this.wrapRemoveLeft = function(editor, __removeLeft)
{
if (!this.insertMatching) {
__removeLeft.call(editor);
return;
}

if (editor.$readOnly)
return;

var secondaryDeletion = null;
if (editor.selection.isEmpty()) {
editor.selection.selectLeft();
var text = editor.session.getDocument().getTextRange(editor.selection.getRange());
if (this.$reOpen.test(text))
{
var nextCharRng = Range.fromPoints(editor.selection.getRange().end, {
row: editor.selection.getRange().end.row,
column: editor.selection.getRange().end.column + 1
});
var nextChar = editor.session.getDocument().getTextRange(nextCharRng);
if (nextChar == this.$complements[text])
{
secondaryDeletion = editor.getSelectionRange();
}
}
}

editor.session.remove(editor.getSelectionRange());
if (secondaryDeletion)
editor.session.remove(secondaryDeletion);
editor.clearSelection();
};

this.$moveLeft = function(doc, pos)
{
if (pos.row == 0 && pos.column == 0)
Expand Down Expand Up @@ -159,46 +193,6 @@ define("mode/auto_brace_insert", function(require, exports, module)
else
return {row: row, column: col};
};

this.$attachBehavioursIfNeeded = function() {
if (this.$autoBraceInsertBehaviorsAttached)
return;

this.$autoBraceInsertBehaviorsAttached = true;

this.$behaviour.add('auto_insert', 'deletion',
function(state, action, editor, session, range) {
if (!this.insertMatching) {
return false;
}

if (editor.getReadOnly())
return false;

var text = session.getDocument().getTextRange(range);
if (this.$reOpen.test(text))
{
var nextCharRng = Range.fromPoints(range.end, {
row: editor.selection.getRange().end.row,
column: editor.selection.getRange().end.column + 1
});
var nextChar = session.getDocument().getTextRange(nextCharRng);
if (nextChar == this.$complements[text])
{
return Range.fromPoints(range.start, nextCharRng.end);
}
}

return false;
});
};

var __transformAction = this.transformAction;
this.transformAction = function(state, action, editor, session, param) {
this.$attachBehavioursIfNeeded();
return __transformAction.apply(this, arguments);
};

}).call(TextMode.prototype);

exports.setInsertMatching = function(insertMatching) {
Expand Down
1 change: 0 additions & 1 deletion src/gwt/acesupport/acemode/r.js
Expand Up @@ -32,7 +32,6 @@ define("mode/r", function(require, exports, module)

var Mode = function(suppressHighlighting, doc)
{
TextMode.call(this);
if (suppressHighlighting)
this.$tokenizer = new Tokenizer(new TextHighlightRules().getRules());
else
Expand Down
1 change: 0 additions & 1 deletion src/gwt/acesupport/acemode/rdoc.js
Expand Up @@ -25,7 +25,6 @@ var RDocHighlightRules = require("mode/rdoc_highlight_rules").RDocHighlightRules
var MatchingBraceOutdent = require("ace/mode/matching_brace_outdent").MatchingBraceOutdent;

var Mode = function(suppressHighlighting) {
TextMode.call(this);
if (suppressHighlighting)
this.$tokenizer = new Tokenizer(new TextHighlightRules().getRules());
else
Expand Down
1 change: 0 additions & 1 deletion src/gwt/acesupport/acemode/sweave.js
Expand Up @@ -26,7 +26,6 @@ var RCodeModel = require("mode/r_code_model").RCodeModel;
var MatchingBraceOutdent = require("ace/mode/matching_brace_outdent").MatchingBraceOutdent;

var Mode = function(suppressHighlighting, doc) {
TextMode.call(this);
if (suppressHighlighting)
this.$tokenizer = new Tokenizer(new TextHighlightRules().getRules());
else
Expand Down
1 change: 0 additions & 1 deletion src/gwt/acesupport/acemode/tex.js
Expand Up @@ -25,7 +25,6 @@ var TexHighlightRules = require("mode/tex_highlight_rules").TexHighlightRules;
var MatchingBraceOutdent = require("ace/mode/matching_brace_outdent").MatchingBraceOutdent;

var Mode = function(suppressHighlighting) {
TextMode.call(this);
if (suppressHighlighting)
this.$tokenizer = new Tokenizer(new TextHighlightRules().getRules());
else
Expand Down

0 comments on commit 8210ac8

Please sign in to comment.