Skip to content

Autoscroll when extending cell select (#13353) #13354

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 10, 2020
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