From fa5c7f3eb3f85c69a7cfc6fa8503ff740a0f48f9 Mon Sep 17 00:00:00 2001 From: nightwing Date: Fri, 28 Jan 2011 21:36:59 +0800 Subject: [PATCH] don't copy empty strings --- lib/ace/keyboard/textinput.js | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/lib/ace/keyboard/textinput.js b/lib/ace/keyboard/textinput.js index dded6dc0..f4ecac17 100644 --- a/lib/ace/keyboard/textinput.js +++ b/lib/ace/keyboard/textinput.js @@ -101,18 +101,25 @@ var TextInput = function(parentNode, host) { }, 0); }; - var onCopy = function() { + var onCopy = function(e) { copied = true; - text.value = host.getCopyText(); + var copyText = host.getCopyText(); + if(copyText) + text.value = copyText; + else + e.preventDefault(); text.select(); - copied = true; setTimeout(sendText, 0); }; - var onCut = function() { + var onCut = function(e) { copied = true; - text.value = host.getCopyText(); - host.onCut(); + var copyText = host.getCopyText(); + if(copyText) { + text.value = copyText; + host.onCut(); + } else + e.preventDefault(); text.select(); setTimeout(sendText, 0); };