From b8e934b1bf59025dec8872f9f783dac56dcf1f2e Mon Sep 17 00:00:00 2001 From: nightwing Date: Sun, 23 Oct 2011 01:22:51 +0500 Subject: [PATCH 1/3] make wrapping friendlier to code: - allow wrapping text at punctuation as well as space - do not search for wrap point too far away from the line end --- lib/ace/edit_session.js | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/lib/ace/edit_session.js b/lib/ace/edit_session.js index 9f22e284..6697a10c 100644 --- a/lib/ace/edit_session.js +++ b/lib/ace/edit_session.js @@ -1197,6 +1197,7 @@ var EditSession = function(text, mode) { CHAR_EXT = 2, PLACEHOLDER_START = 3, PLACEHOLDER_BODY = 4, + PUNCTUATION = 9, SPACE = 10, TAB = 11, TAB_SPACE = 12; @@ -1240,7 +1241,7 @@ var EditSession = function(text, mode) { // a split is simple. if (tokens[split] >= SPACE) { // Include all following spaces + tabs in this split as well. - while (tokens[split] >= SPACE) { + while (tokens[split] >= SPACE) { split ++; } addSplit(split); @@ -1295,16 +1296,16 @@ var EditSession = function(text, mode) { } // === ELSE === - // Search for the first non space/tab/placeholder token backwards. - for (split; split != lastSplit - 1; split--) { - if (tokens[split] >= PLACEHOLDER_START) { - split++; - break; - } + // Search for the first non space/tab/placeholder/punctuation token backwards. + var minSplit = Math.max(split - 10, lastSplit - 1); + while (split > minSplit && tokens[split] < PLACEHOLDER_START) { + split --; } // If we found one, then add the split. - if (split > lastSplit) { - addSplit(split); + if (split > minSplit) { + while(split > minSplit && tokens[split] == PUNCTUATION) + split --; + addSplit(++split); continue; } @@ -1312,7 +1313,7 @@ var EditSession = function(text, mode) { split = lastSplit + wrapLimit; // The split is inside of a CHAR or CHAR_EXT token and no space // around -> force a split. - addSplit(lastSplit + wrapLimit); + addSplit(split); } return splits; } @@ -1338,11 +1339,13 @@ var EditSession = function(text, mode) { } } // Space - else if(c == 32) { + else if (c == 32) { arr.push(SPACE); + } else if((c > 39 && c < 48) || (c > 57 && c < 64)) { + arr.push(PUNCTUATION); } // full width characters - else if (isFullWidth(c)) { + else if (c >= 0x1100 && isFullWidth(c)) { arr.push(CHAR, CHAR_EXT); } else { arr.push(CHAR); @@ -1378,7 +1381,7 @@ var EditSession = function(text, mode) { screenColumn += this.getScreenTabSize(screenColumn); } // full width characters - else if (isFullWidth(c)) { + else if (c >= 0x1100 && isFullWidth(c)) { screenColumn += 2; } else { screenColumn += 1; From 6b84933232b741ee509771b6987ac0ac7151a820 Mon Sep 17 00:00:00 2001 From: KJ Date: Wed, 26 Oct 2011 14:16:17 +0800 Subject: [PATCH 2/3] fix vim mode (h|left) and (l|right) key --- lib/ace/keyboard/keybinding/vim.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/ace/keyboard/keybinding/vim.js b/lib/ace/keyboard/keybinding/vim.js index c3a321f5..90c7dc15 100644 --- a/lib/ace/keyboard/keybinding/vim.js +++ b/lib/ace/keyboard/keybinding/vim.js @@ -93,8 +93,8 @@ var vimStates = { }, vimcommand("(k|up)", "golineup"), vimcommand("(j|down)", "golinedown"), - vimcommand("(l|right)", "golineright"), - vimcommand("(h|left)", "golineleft"), + vimcommand("(l|right)", "gotoright"), + vimcommand("(h|left)", "gotoleft"), { key: "shift-g", exec: "gotoend" From 2ad5f9a3a06da0ea9e43e8fa66d4dbe1d7282885 Mon Sep 17 00:00:00 2001 From: Fabian Jakobs Date: Wed, 26 Oct 2011 10:30:11 +0300 Subject: [PATCH 3/3] highlight "no" keyword in coffeescript. fixes #481 --- lib/ace/mode/coffee_highlight_rules.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/ace/mode/coffee_highlight_rules.js b/lib/ace/mode/coffee_highlight_rules.js index a0aa173e..a249479e 100644 --- a/lib/ace/mode/coffee_highlight_rules.js +++ b/lib/ace/mode/coffee_highlight_rules.js @@ -54,7 +54,7 @@ define(function(require, exports, module) { var keywords = lang.arrayToMap(( "this|throw|then|try|typeof|super|switch|return|break|by)|continue|" + "catch|class|in|instanceof|is|isnt|if|else|extends|for|forown|" + - "finally|function|while|when|new|not|delete|debugger|do|loop|of|off|" + + "finally|function|while|when|new|no|not|delete|debugger|do|loop|of|off|" + "or|on|unless|until|and|yes").split("|") );