Skip to content
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
26 changes: 18 additions & 8 deletions src/client/datascience/editor-integration/codewatcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -552,18 +552,23 @@ export class CodeWatcher implements ICodeWatcher {
}
editor.selection = selection;
} else {
let newCell: ICellRange | undefined;
// full cell range is selected now decide if expanding or contracting?
if (isAnchorLessThanActive && startCellIndex < endCellIndex) {
// anchor is above active, contract selection by cell below.
const newEndCell = cells[endCellIndex - 1];
editor.selection = new Selection(startCell.range.start, newEndCell.range.end);
newCell = cells[endCellIndex - 1];
editor.selection = new Selection(startCell.range.start, newCell.range.end);
} else {
// anchor is below active, expand selection by cell above.
if (startCellIndex > 0) {
const aboveCell = cells[startCellIndex - 1];
editor.selection = new Selection(endCell.range.end, aboveCell.range.start);
newCell = cells[startCellIndex - 1];
editor.selection = new Selection(endCell.range.end, newCell.range.start);
}
}

if (newCell) {
editor.revealRange(newCell.range, TextEditorRevealType.Default);
}
}
}

Expand Down Expand Up @@ -613,20 +618,25 @@ export class CodeWatcher implements ICodeWatcher {
}
editor.selection = selection;
} else {
let newCell: ICellRange | undefined;
// full cell range is selected now decide if expanding or contracting?
if (isAnchorLessEqualActive || startCellIndex === endCellIndex) {
// anchor is above active, expand selection by cell below.
if (endCellIndex < cells.length - 1) {
const extendCell = cells[endCellIndex + 1];
editor.selection = new Selection(startCell.range.start, extendCell.range.end);
newCell = cells[endCellIndex + 1];
editor.selection = new Selection(startCell.range.start, newCell.range.end);
}
} else {
// anchor is below active, contract selection by cell above.
if (startCellIndex < endCellIndex) {
const contractCell = cells[startCellIndex + 1];
editor.selection = new Selection(endCell.range.end, contractCell.range.start);
newCell = cells[startCellIndex + 1];
editor.selection = new Selection(endCell.range.end, newCell.range.start);
}
}

if (newCell) {
editor.revealRange(newCell.range, TextEditorRevealType.Default);
}
}
}

Expand Down