commit
42d243df4b
11 changed files with 61 additions and 80 deletions
|
|
@ -946,7 +946,8 @@ var EditSession = function(text, mode) {
|
|||
this.tokenRe = mode.tokenRe;
|
||||
this.nonTokenRe = mode.nonTokenRe;
|
||||
|
||||
|
||||
this.$options.wrapMethod.set.call(this, this.$wrapMethod);
|
||||
|
||||
if (!$isPlaceholder) {
|
||||
this.$setFolding(mode.foldingRules);
|
||||
this._emit("changeMode");
|
||||
|
|
@ -1791,7 +1792,7 @@ var EditSession = function(text, mode) {
|
|||
while (row <= lastRow) {
|
||||
foldLine = this.getFoldLine(row, foldLine);
|
||||
if (!foldLine) {
|
||||
tokens = this.$getDisplayTokens(lang.stringTrimRight(lines[row]));
|
||||
tokens = this.$getDisplayTokens(lines[row]);
|
||||
wrapData[row] = this.$computeWrapSplits(tokens, wrapLimit, tabSize);
|
||||
row ++;
|
||||
} else {
|
||||
|
|
@ -1815,9 +1816,6 @@ var EditSession = function(text, mode) {
|
|||
foldLine.end.row,
|
||||
lines[foldLine.end.row].length + 1
|
||||
);
|
||||
// Remove spaces/tabs from the back of the token array.
|
||||
while (tokens.length != 0 && tokens[tokens.length - 1] >= SPACE)
|
||||
tokens.pop();
|
||||
|
||||
wrapData[foldLine.start.row]
|
||||
= this.$computeWrapSplits(tokens, wrapLimit, tabSize);
|
||||
|
|
@ -1846,6 +1844,8 @@ var EditSession = function(text, mode) {
|
|||
var displayLength = tokens.length;
|
||||
var lastSplit = 0, lastDocSplit = 0;
|
||||
|
||||
var isCode = this.$wrapAsCode;
|
||||
|
||||
function addSplit(screenPos) {
|
||||
var displayed = tokens.slice(lastSplit, screenPos);
|
||||
|
||||
|
|
@ -1873,11 +1873,12 @@ var EditSession = function(text, mode) {
|
|||
|
||||
// If there is a space or tab at this split position, then making
|
||||
// a split is simple.
|
||||
if (tokens[split] >= SPACE) {
|
||||
if (tokens[split - 1] >= SPACE && tokens[split] >= SPACE) {
|
||||
/* disabled see https://github.com/ajaxorg/ace/issues/1186
|
||||
// Include all following spaces + tabs in this split as well.
|
||||
while (tokens[split] >= SPACE) {
|
||||
split ++;
|
||||
}
|
||||
} */
|
||||
addSplit(split);
|
||||
continue;
|
||||
}
|
||||
|
|
@ -1886,9 +1887,7 @@ var EditSession = function(text, mode) {
|
|||
// Check if split is inside of a placeholder. Placeholder are
|
||||
// not splitable. Therefore, seek the beginning of the placeholder
|
||||
// and try to place the split beofre the placeholder's start.
|
||||
if (tokens[split] == PLACEHOLDER_START
|
||||
|| tokens[split] == PLACEHOLDER_BODY)
|
||||
{
|
||||
if (tokens[split] == PLACEHOLDER_START || tokens[split] == PLACEHOLDER_BODY) {
|
||||
// Seek the start of the placeholder and do the split
|
||||
// before the placeholder. By definition there always
|
||||
// a PLACEHOLDER_START between split and lastSplit.
|
||||
|
|
@ -1912,8 +1911,7 @@ var EditSession = function(text, mode) {
|
|||
// placeholder. So, let's seek for the end of the placeholder.
|
||||
split = lastSplit + wrapLimit;
|
||||
for (split; split < tokens.length; split++) {
|
||||
if (tokens[split] != PLACEHOLDER_BODY)
|
||||
{
|
||||
if (tokens[split] != PLACEHOLDER_BODY) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
@ -1931,12 +1929,21 @@ var EditSession = function(text, mode) {
|
|||
|
||||
// === ELSE ===
|
||||
// Search for the first non space/tab/placeholder/punctuation token backwards.
|
||||
var minSplit = Math.max(split - 10, lastSplit - 1);
|
||||
var minSplit = Math.max(split - (isCode ? 10 : wrapLimit-(wrapLimit>>2)), lastSplit - 1);
|
||||
while (split > minSplit && tokens[split] < PLACEHOLDER_START) {
|
||||
split --;
|
||||
}
|
||||
while (split > minSplit && tokens[split] == PUNCTUATION) {
|
||||
split --;
|
||||
if (isCode) {
|
||||
while (split > minSplit && tokens[split] < PLACEHOLDER_START) {
|
||||
split --;
|
||||
}
|
||||
while (split > minSplit && tokens[split] == PUNCTUATION) {
|
||||
split --;
|
||||
}
|
||||
} else {
|
||||
while (split > minSplit && tokens[split] < SPACE) {
|
||||
split --;
|
||||
}
|
||||
}
|
||||
// If we found one, then add the split.
|
||||
if (split > minSplit) {
|
||||
|
|
@ -2441,6 +2448,16 @@ config.defineOptions(EditSession.prototype, "session", {
|
|||
return this.getUseWrapMode() ? this.getWrapLimitRange().min || "free" : "off";
|
||||
},
|
||||
handlesSet: true
|
||||
},
|
||||
wrapMethod: {
|
||||
// code|text|auto
|
||||
set: function(val) {
|
||||
if (val == "auto")
|
||||
this.$wrapAsCode = this.$mode.type != "text";
|
||||
else
|
||||
this.$wrapAsCode = val != "text";
|
||||
},
|
||||
initialValue: "auto"
|
||||
},
|
||||
firstLineNumber: {
|
||||
set: function() {this._emit("changeBreakpoint");},
|
||||
|
|
|
|||
|
|
@ -386,11 +386,12 @@ module.exports = {
|
|||
assert.ok(splits[i] == assertEqual[i]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
EditSession.prototype.$wrapAsCode = true;
|
||||
// Basic splitting.
|
||||
computeAndAssert("foo bar foo bar", [ 12 ]);
|
||||
computeAndAssert("foo bar f bar", [ 12 ]);
|
||||
computeAndAssert("foo bar f r", [ 14 ]);
|
||||
computeAndAssert("foo bar f r", [ 12 ]); // 14 if we enable
|
||||
computeAndAssert("foo bar foo bar foo bara foo", [12, 25]);
|
||||
|
||||
// Don't split if there is only whitespaces/tabs at the end of the line.
|
||||
|
|
@ -406,7 +407,7 @@ module.exports = {
|
|||
computeAndAssert("foo \t \tbar", [ 7 ]);
|
||||
|
||||
// Ignore spaces/tabs at beginning of split.
|
||||
computeAndAssert("foo \t \t \t \t bar", [ 14 ]);
|
||||
computeAndAssert("foo \t \t \t \t bar", [ 7 ]); // 14
|
||||
|
||||
// Test wrapping for asian characters.
|
||||
computeAndAssert("ぁぁ", [1], 2);
|
||||
|
|
@ -418,6 +419,10 @@ module.exports = {
|
|||
computeAndAssert(" ab.c;ef++", [1, 3, 5, 7, 8], 2);
|
||||
computeAndAssert(" a.b", [1, 2, 3], 1);
|
||||
computeAndAssert("#>>", [1, 2], 1);
|
||||
|
||||
// Test wrapping for punctuation in
|
||||
EditSession.prototype.$wrapAsCode = false;
|
||||
computeAndAssert("ab cde, Juhu kinners", [3, 8, 13, 19], 6);
|
||||
},
|
||||
|
||||
"test get longest line" : function() {
|
||||
|
|
|
|||
|
|
@ -226,7 +226,7 @@ var Editor = function(renderer, session) {
|
|||
_self.keyBinding.setKeyboardHandler(module && module.handler);
|
||||
});
|
||||
} else {
|
||||
delete this.$keybindingId;
|
||||
this.$keybindingId = null;
|
||||
this.keyBinding.setKeyboardHandler(keyboardHandler);
|
||||
}
|
||||
};
|
||||
|
|
|
|||
|
|
@ -457,9 +457,9 @@ var Text = function(parentEl) {
|
|||
return screenColumn + value.length;
|
||||
};
|
||||
|
||||
this.renderIndentGuide = function(stringBuilder, value) {
|
||||
this.renderIndentGuide = function(stringBuilder, value, max) {
|
||||
var cols = value.search(this.$indentGuideRe);
|
||||
if (cols <= 0)
|
||||
if (cols <= 0 || cols >= max)
|
||||
return value;
|
||||
if (value[0] == " ") {
|
||||
cols -= cols % this.tabSize;
|
||||
|
|
@ -483,7 +483,7 @@ var Text = function(parentEl) {
|
|||
var value = token.value;
|
||||
if (i == 0 && this.displayIndentGuides) {
|
||||
chars = value.length;
|
||||
value = this.renderIndentGuide(stringBuilder, value);
|
||||
value = this.renderIndentGuide(stringBuilder, value, splitChars);
|
||||
if (!value)
|
||||
continue;
|
||||
chars -= value.length;
|
||||
|
|
|
|||
|
|
@ -46,6 +46,7 @@ var Mode = function() {
|
|||
oop.inherits(Mode, TextMode);
|
||||
|
||||
(function() {
|
||||
this.type = "text";
|
||||
this.getNextLineIndent = function(state, line, tab) {
|
||||
if (state == "listblock") {
|
||||
var match = /^((?:.+)?)([-+*][ ]+)/.exec(line);
|
||||
|
|
|
|||
|
|
@ -26,11 +26,6 @@
|
|||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
*
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
/*
|
||||
|
|
|
|||
|
|
@ -1075,50 +1075,15 @@ exports.register = function (linter) {
|
|||
},
|
||||
{}],
|
||||
7:[function(req,module,exports){
|
||||
(function(global){/*global window, global*/
|
||||
var functions = [
|
||||
[log, "log"]
|
||||
, [info, "info"]
|
||||
, [warn, "warn"]
|
||||
, [error, "error"]
|
||||
, [time, "time"]
|
||||
, [timeEnd, "timeEnd"]
|
||||
, [trace, "trace"]
|
||||
, [dir, "dir"]
|
||||
, [assert, "assert"]
|
||||
]
|
||||
[
|
||||
"log", "info", "warn", "error", "time",
|
||||
"timeEnd", "trace", "dir", "assert"
|
||||
].forEach(function(x) {
|
||||
exports[x] = nop;
|
||||
});
|
||||
|
||||
for (var i = 0; i < functions.length; i++) {
|
||||
var tuple = functions[i]
|
||||
var f = tuple[0]
|
||||
var name = tuple[1]
|
||||
function nop() {}
|
||||
|
||||
if (!console[name]) {
|
||||
console[name] = f
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = console
|
||||
|
||||
function log() {}
|
||||
|
||||
function info() {}
|
||||
|
||||
function warn() {}
|
||||
|
||||
function error() {}
|
||||
|
||||
function time(label) {}
|
||||
|
||||
function timeEnd(label) {}
|
||||
|
||||
function trace() {}
|
||||
|
||||
function dir(object) {}
|
||||
|
||||
function assert(expression) {}
|
||||
|
||||
})(window)
|
||||
},
|
||||
{}],
|
||||
"jshint":[function(req,module,exports){
|
||||
|
|
|
|||
|
|
@ -56,7 +56,7 @@ var Mode = function() {
|
|||
oop.inherits(Mode, TextMode);
|
||||
|
||||
(function() {
|
||||
|
||||
this.type = "text";
|
||||
this.lineCommentStart = ">";
|
||||
|
||||
this.getNextLineIndent = function(state, line, tab) {
|
||||
|
|
|
|||
|
|
@ -38,18 +38,17 @@ var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
|
|||
var Behaviour = require("./behaviour").Behaviour;
|
||||
|
||||
var Mode = function() {
|
||||
this.$tokenizer = new Tokenizer(new TextHighlightRules().getRules());
|
||||
this.$behaviour = new Behaviour();
|
||||
this.$tokenizer = new Tokenizer(new TextHighlightRules().getRules());
|
||||
this.$behaviour = new Behaviour();
|
||||
};
|
||||
|
||||
oop.inherits(Mode, TextMode);
|
||||
|
||||
(function() {
|
||||
|
||||
this.getNextLineIndent = function(state, line, tab) {
|
||||
return '';
|
||||
};
|
||||
|
||||
this.type = "text";
|
||||
this.getNextLineIndent = function(state, line, tab) {
|
||||
return '';
|
||||
};
|
||||
}).call(Mode.prototype);
|
||||
|
||||
exports.Mode = Mode;
|
||||
|
|
|
|||
|
|
@ -8,8 +8,7 @@
|
|||
background: #f6f6f6
|
||||
}
|
||||
|
||||
.ace-tomorrow,
|
||||
.ace-tomorrow .ace_scroller {
|
||||
.ace-tomorrow {
|
||||
background-color: #FFFFFF;
|
||||
color: #4D4D4C
|
||||
}
|
||||
|
|
|
|||
|
|
@ -990,7 +990,7 @@ var VirtualRenderer = function(container, theme) {
|
|||
|
||||
this.$getLongestLine = function() {
|
||||
var charCount = this.session.getScreenWidth();
|
||||
if (this.$textLayer.showInvisibles)
|
||||
if (this.showInvisibles && !this.session.$useWrapMode)
|
||||
charCount += 1;
|
||||
|
||||
return Math.max(this.$size.scrollerWidth - 2 * this.$padding, Math.round(charCount * this.characterWidth));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue