From 0ee2a056b84b75edc6849f5ccb9c7b0a09b00ef7 Mon Sep 17 00:00:00 2001 From: nightwing Date: Fri, 10 Apr 2015 15:20:16 +0400 Subject: [PATCH] prevent undo in ace changing focus --- plugins/c9.ide.ace/ace.js | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/plugins/c9.ide.ace/ace.js b/plugins/c9.ide.ace/ace.js index d2a27b33..43d2ea37 100644 --- a/plugins/c9.ide.ace/ace.js +++ b/plugins/c9.ide.ace/ace.js @@ -534,7 +534,7 @@ define(function(require, exports, module) { editor = apf.activeElement; if (!isAce(editor, true)) return false; - if (!editor.ace.commands.byName[command.name]) + if (!editor.ace.commands.byName[command.name] && !command.shared) return false; return isAvailable ? isAvailable(editor.ace) : true; @@ -582,6 +582,21 @@ define(function(require, exports, module) { commands.addCommand(commands.commands.togglerecording, handle); commands.addCommand(commands.commands.replaymacro, handle); + // when event for cmd-z in textarea is not canceled + // chrome tries to find another textarea with pending undo and focus it + // we do not want this to happen when ace instance is focused + commands.addCommand(fnWrap({ + name: "cancelBrowserUndoInAce", + bindKey: { + mac: "Cmd-Z|Cmd-Shift-Z|Cmd-Y", + win: "Ctrl-Z|Ctrl-Shift-Z|Ctrl-Y", + position: -10000 + }, + group: "ignore", + exec: function(e) {}, + readOnly: true, + shared: true + }), handle); function sharedCommand(command) { command.isAvailable = function(editor) { return editor && editor.type == "ace";