Fix selection

This commit is contained in:
Florian Mounier
2016-10-13 16:25:18 +02:00
parent 08ecb4d0d2
commit da659b7526
3 changed files with 12 additions and 11 deletions

View File

@@ -413,13 +413,13 @@
Selection.prototype.go = function(n) {
var index;
index = butterfly.children.indexOf(this.startLine) + n;
if (!((0 <= index && index < butterfly.children.length))) {
index = Array.prototype.indexOf.call(butterfly.term.childNodes, this.startLine) + n;
if (!((0 <= index && index < butterfly.term.childElementCount))) {
return;
}
while (!butterfly.children[index].textContent.match(/\S/)) {
while (!butterfly.term.childNodes[index].textContent.match(/\S/)) {
index += n;
if (!((0 <= index && index < butterfly.children.length))) {
if (!((0 <= index && index < butterfly.term.childElementCount))) {
return;
}
}
@@ -437,7 +437,7 @@
Selection.prototype.selectLine = function(index) {
var line, lineEnd, lineStart;
line = butterfly.children[index];
line = butterfly.term.childNodes[index];
lineStart = {
node: line.firstChild,
offset: 0

File diff suppressed because one or more lines are too long

View File

@@ -87,12 +87,13 @@ class Selection
@go +1
go: (n) ->
index = butterfly.children.indexOf(@startLine) + n
return unless 0 <= index < butterfly.children.length
index = Array.prototype.indexOf.call(
butterfly.term.childNodes, @startLine) + n
return unless 0 <= index < butterfly.term.childElementCount
until butterfly.children[index].textContent.match /\S/
until butterfly.term.childNodes[index].textContent.match /\S/
index += n
return unless 0 <= index < butterfly.children.length
return unless 0 <= index < butterfly.term.childElementCount
@selectLine index
@@ -104,7 +105,7 @@ class Selection
@selection.addRange range
selectLine: (index) ->
line = butterfly.children[index]
line = butterfly.term.childNodes[index]
lineStart =
node: line.firstChild
offset: 0