fix #325
This commit is contained in:
parent
964829f031
commit
5a6eeab67d
5 changed files with 59 additions and 13 deletions
|
|
@ -1370,7 +1370,8 @@ var EditSession = function(text, mode) {
|
|||
}
|
||||
|
||||
this.getScreenLastRowColumn = function(screenRow) {
|
||||
return this.screenToDocumentColumn(screenRow, Number.MAX_VALUE / 10)
|
||||
//return this.screenToDocumentColumn(screenRow, Number.MAX_VALUE / 10)
|
||||
return this.documentToScreenColumn(screenRow, this.doc.getLine(screenRow).length);
|
||||
};
|
||||
|
||||
this.getDocumentLastRowColumn = function(docRow, docColumn) {
|
||||
|
|
|
|||
|
|
@ -155,6 +155,18 @@ module.exports = {
|
|||
assert.equal(session.getValue(), ["1", "1", "2", "3"].join("\n"));
|
||||
},
|
||||
|
||||
"test: getScreenLastRowColumn": function() {
|
||||
var session = new EditSession([
|
||||
"juhu",
|
||||
"12\t\t34",
|
||||
"ぁぁa"
|
||||
]);
|
||||
|
||||
assert.equal(session.getScreenLastRowColumn(0), 4);
|
||||
assert.equal(session.getScreenLastRowColumn(1), 10);
|
||||
assert.equal(session.getScreenLastRowColumn(2), 5);
|
||||
},
|
||||
|
||||
"test: convert document to screen coordinates" : function() {
|
||||
var session = new EditSession("01234\t567890\t1234");
|
||||
session.setTabSize(4);
|
||||
|
|
@ -187,9 +199,20 @@ module.exports = {
|
|||
assert.equal(session.documentToScreenColumn(0, 3), 9);
|
||||
},
|
||||
|
||||
"test: documentToScreen with soft wrap and multibyte characters": function() {
|
||||
var tabSize = 4;
|
||||
var wrapLimit = 12;
|
||||
"test: documentToScreen without soft wrap": function() {
|
||||
var session = new EditSession([
|
||||
"juhu",
|
||||
"12\t\t34",
|
||||
"ぁぁa"
|
||||
]);
|
||||
|
||||
assert.position(session.documentToScreenPosition(0, 3), 0, 3);
|
||||
assert.position(session.documentToScreenPosition(1, 3), 1, 4);
|
||||
assert.position(session.documentToScreenPosition(1, 4), 1, 8);
|
||||
assert.position(session.documentToScreenPosition(2, 2), 2, 4);
|
||||
},
|
||||
|
||||
"test: documentToScreen with soft wrap": function() {
|
||||
var session = new EditSession(["foo bar foo bar"]);
|
||||
session.setUseWrapMode(true);
|
||||
session.setWrapLimitRange(12, 12);
|
||||
|
|
@ -197,6 +220,9 @@ module.exports = {
|
|||
|
||||
assert.position(session.documentToScreenPosition(0, 11), 0, 11);
|
||||
assert.position(session.documentToScreenPosition(0, 12), 1, 0);
|
||||
},
|
||||
|
||||
"test: documentToScreen with soft wrap and multibyte characters": function() {
|
||||
|
||||
session = new EditSession(["ぁぁa"]);
|
||||
session.setUseWrapMode(true);
|
||||
|
|
|
|||
|
|
@ -81,9 +81,9 @@ var Marker = function(parentEl) {
|
|||
range = range.toScreenRange(this.session);
|
||||
if (marker.renderer) {
|
||||
var top = this.$getTop(range.start.row, config);
|
||||
var left = Math.round(this.$padding +
|
||||
range.start.column *
|
||||
config.characterWidth);
|
||||
var left = Math.round(
|
||||
this.$padding + range.start.column * config.characterWidth
|
||||
);
|
||||
marker.renderer(html, range, left, top, config);
|
||||
}
|
||||
else if (range.isMultiLine()) {
|
||||
|
|
@ -185,15 +185,11 @@ var Marker = function(parentEl) {
|
|||
);
|
||||
};
|
||||
|
||||
<<<<<<< HEAD
|
||||
this.drawSingleLineMarker = function(stringBuilder, range, clazz, layerConfig, extraLength, ignorePadding) {
|
||||
var padding = ignorePadding ? 0 : this.$padding;
|
||||
=======
|
||||
/**
|
||||
* Draws a marker which covers one single full line
|
||||
*/
|
||||
this.drawSingleLineMarker = function(stringBuilder, range, clazz, layerConfig, extraLength) {
|
||||
>>>>>>> Update desired column on insert text
|
||||
this.drawSingleLineMarker = function(stringBuilder, range, clazz, layerConfig, extraLength, ignorePadding) {
|
||||
var padding = ignorePadding ? 0 : this.$padding;
|
||||
var height = layerConfig.lineHeight;
|
||||
var width = Math.round((range.end.column + (extraLength || 0) - range.start.column) * layerConfig.characterWidth);
|
||||
var top = this.$getTop(range.start.row, layerConfig);
|
||||
|
|
|
|||
|
|
@ -290,6 +290,7 @@ var Range = function(startRow, startColumn, endRow, endColumn) {
|
|||
session.documentToScreenPosition(this.start);
|
||||
var screenPosEnd =
|
||||
session.documentToScreenPosition(this.end);
|
||||
|
||||
return new Range(
|
||||
screenPosStart.row, screenPosStart.column,
|
||||
screenPosEnd.row, screenPosEnd.column
|
||||
|
|
|
|||
|
|
@ -42,6 +42,7 @@ if (typeof process !== "undefined") {
|
|||
define(function(require, exports, module) {
|
||||
|
||||
var Range = require("ace/range").Range;
|
||||
var EditSession = require("ace/edit_session").EditSession;
|
||||
var assert = require("ace/test/assertions");
|
||||
|
||||
module.exports = {
|
||||
|
|
@ -165,6 +166,27 @@ module.exports = {
|
|||
|
||||
var range = new Range(2, 0, 2, 0);
|
||||
assert.range(range.collapseRows(), 2, 0, 2, 0);
|
||||
},
|
||||
|
||||
"test: to screen range" : function() {
|
||||
var session = new EditSession([
|
||||
"juhu",
|
||||
"12\t\t34",
|
||||
"ぁぁa",
|
||||
"\t\t34",
|
||||
]);
|
||||
|
||||
var range = new Range(0, 0, 0, 3);
|
||||
assert.range(range.toScreenRange(session), 0, 0, 0, 3);
|
||||
|
||||
var range = new Range(1, 1, 1, 3);
|
||||
assert.range(range.toScreenRange(session), 1, 1, 1, 4);
|
||||
|
||||
var range = new Range(2, 1, 2, 2);
|
||||
assert.range(range.toScreenRange(session), 2, 2, 2, 4);
|
||||
|
||||
var range = new Range(3, 0, 3, 4);
|
||||
assert.range(range.toScreenRange(session), 3, 0, 3, 10);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue