Skip to content

Commit

Permalink
handle negative range
Browse files Browse the repository at this point in the history
  • Loading branch information
jhchen committed Jul 4, 2018
1 parent 8dfdc7c commit f30d524
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion core/quill.js
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,7 @@ class Quill {
this.selection.setRange(null, length || Quill.sources.API);
} else {
[index, length, , source] = overload(index, length, source);
this.selection.setRange(new Range(index, length), source);
this.selection.setRange(new Range(Math.max(0, index), length), source);
if (source !== Emitter.sources.SILENT) {
this.selection.scrollIntoView(this.scrollingContainer);
}
Expand Down
2 changes: 1 addition & 1 deletion modules/keyboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ Keyboard.DEFAULTS = {
const { event, line: cell } = context;
const offset = cell.offset(this.quill.scroll);
if (event.shiftKey) {
this.quill.setSelection(Math.max(0, offset - 1), Quill.sources.USER);
this.quill.setSelection(offset - 1, Quill.sources.USER);
} else {
this.quill.setSelection(offset + cell.length(), Quill.sources.USER);
}
Expand Down

0 comments on commit f30d524

Please sign in to comment.