From 399ee950275814cc1d440ec064e9a2d4ff213f47 Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Thu, 9 Sep 2010 16:27:58 +0200 Subject: [PATCH] Removing a tab (i.e. 4 spaces) on backspace now --- README.mdown | 1 + php-console.js | 12 ++++++++++++ 2 files changed, 13 insertions(+) diff --git a/README.mdown b/README.mdown index 334f7e7..9f9f77e 100644 --- a/README.mdown +++ b/README.mdown @@ -35,6 +35,7 @@ Changelog - Added a status bar with char/line display - Added a toggle button to expand/collapse all krumo sub-trees at once - Cross-browser compatibility enhancements + - Removing a tab (i.e. 4 spaces) on backspace now - 1.0.0 - Initial Public Release diff --git a/php-console.js b/php-console.js index 02bc706..832d911 100644 --- a/php-console.js +++ b/php-console.js @@ -62,6 +62,18 @@ $(function() { e.preventDefault(); } break; + case 8: + // deindent automatically on backspace + caret = $(this).getCaret(); + part = $(this).val().substr(0, caret); + if (part.match(/\n( {4,})$/)) { + $(this).val(function(idx, val) { + return val.substring(0, caret - 4) + val.substring(caret); + }); + $(this).setCaret(caret - 4); + e.preventDefault(); + } + break; } updateStatusBar();