fix text selection for documents with tabs
This commit is contained in:
parent
fb5d93a8a3
commit
39bfb96fde
4 changed files with 16 additions and 11 deletions
|
|
@ -101,6 +101,13 @@ ace.Range = function(startRow, startColumn, endRow, endColumn) {
|
|||
return ace.Range.fromPoints(this.start, this.end);
|
||||
};
|
||||
|
||||
this.toScreenRange = function(doc) {
|
||||
return new ace.Range(
|
||||
this.start.row, doc.documentToScreenColumn(this.start.row, this.start.column),
|
||||
this.end.row, doc.documentToScreenColumn(this.end.row, this.end.column)
|
||||
);
|
||||
};
|
||||
|
||||
}).call(ace.Range.prototype);
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -59,6 +59,7 @@ ace.VirtualRenderer = function(container) {
|
|||
this.setDocument = function(doc) {
|
||||
this.lines = doc.lines;
|
||||
this.doc = doc;
|
||||
this.$cursorLayer.setDocument(doc);
|
||||
this.$markerLayer.setDocument(doc);
|
||||
this.$textLayer.setDocument(doc);
|
||||
};
|
||||
|
|
@ -229,8 +230,6 @@ ace.VirtualRenderer = function(container) {
|
|||
|
||||
|
||||
this.addMarker = function(range, clazz, type) {
|
||||
range.start = this.$documentToScreenPosition(range.start);
|
||||
range.end = this.$documentToScreenPosition(range.end);
|
||||
return this.$markerLayer.addMarker(range, clazz, type);
|
||||
};
|
||||
|
||||
|
|
@ -243,17 +242,10 @@ ace.VirtualRenderer = function(container) {
|
|||
};
|
||||
|
||||
this.updateCursor = function(position, overwrite) {
|
||||
this.$cursorLayer.setCursor(this.$documentToScreenPosition(position), overwrite);
|
||||
this.$cursorLayer.setCursor(position, overwrite);
|
||||
this.$cursorLayer.update(this.layerConfig);
|
||||
};
|
||||
|
||||
this.$documentToScreenPosition = function(pos) {
|
||||
return {
|
||||
row: pos.row,
|
||||
column: this.doc.documentToScreenColumn(pos.row, pos.column)
|
||||
};
|
||||
};
|
||||
|
||||
this.hideCursor = function() {
|
||||
this.$cursorLayer.hideCursor();
|
||||
};
|
||||
|
|
|
|||
|
|
@ -13,10 +13,14 @@ ace.layer.Cursor = function(parentEl) {
|
|||
|
||||
(function() {
|
||||
|
||||
this.setDocument = function(doc) {
|
||||
this.doc = doc;
|
||||
};
|
||||
|
||||
this.setCursor = function(position, overwrite) {
|
||||
this.position = {
|
||||
row : position.row,
|
||||
column : position.column
|
||||
column : this.doc.documentToScreenColumn(position.row, position.column)
|
||||
};
|
||||
if (overwrite) {
|
||||
ace.addCssClass(this.cursor, "ace_overwrite");
|
||||
|
|
|
|||
|
|
@ -84,6 +84,7 @@ ace.layer.Marker = function(parentEl) {
|
|||
};
|
||||
|
||||
this.drawMultiLineMarker = function(stringBuilder, range, clazz, layerConfig) {
|
||||
var range = range.toScreenRange(this.doc);
|
||||
|
||||
// from selection start to the end of the line
|
||||
var height = layerConfig.lineHeight;
|
||||
|
|
@ -125,6 +126,7 @@ ace.layer.Marker = function(parentEl) {
|
|||
};
|
||||
|
||||
this.drawSingleLineMarker = function(stringBuilder, range, clazz, layerConfig) {
|
||||
var range = range.toScreenRange(this.doc);
|
||||
|
||||
var height = layerConfig.lineHeight;
|
||||
var width = Math.round((range.end.column - range.start.column) * layerConfig.characterWidth);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue