Skip to content
This repository was archived by the owner on Sep 6, 2021. It is now read-only.
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions src/editor/EditorCommandHandlers.js
Original file line number Diff line number Diff line change
Expand Up @@ -577,8 +577,11 @@ define(function (require, exports, module) {

var doc = editor.document,
sel = editor.getSelection(),
originalSel = editor.getSelection(),
hasSelection = (sel.start.line !== sel.end.line) || (sel.start.ch !== sel.end.ch);
originalSel = editor.getSelection(),
hasSelection = (sel.start.line !== sel.end.line) || (sel.start.ch !== sel.end.ch),
inlineWidget = EditorManager.getFocusedInlineWidget(),
firstLine = editor.getFirstVisibleLine(),
lastLine = editor.getLastVisibleLine();

sel.start.ch = 0;
// The end of the selection becomes the start of the next line, if it isn't already
Expand All @@ -589,11 +592,11 @@ define(function (require, exports, module) {
// Make the move
switch (direction) {
case DIRECTION_UP:
if (sel.start.line !== 0) {
if (sel.start.line !== firstLine) {
doc.batchOperation(function () {
var prevText = doc.getRange({ line: sel.start.line - 1, ch: 0 }, sel.start);

if (sel.end.line === editor.lineCount()) {
if (sel.end.line === lastLine + 1) {
prevText = "\n" + prevText.substring(0, prevText.length - 1);
}

Expand All @@ -612,12 +615,12 @@ define(function (require, exports, module) {
}
break;
case DIRECTION_DOWN:
if (sel.end.line < editor.lineCount()) {
if (sel.end.line <= lastLine + (inlineWidget ? -1 : 1)) {
doc.batchOperation(function () {
var nextText = doc.getRange(sel.end, { line: sel.end.line + 1, ch: 0 });

var deletionStart = sel.end;
if (sel.end.line === editor.lineCount() - 1) {
if (!inlineWidget && sel.end.line === lastLine) {
nextText += "\n";
deletionStart = { line: sel.end.line - 1, ch: doc.getLine(sel.end.line - 1).length };
}
Expand Down