Skip to content
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

revert default behavior back to previous #194037

Merged
merged 1 commit into from
Sep 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1035,7 +1035,7 @@ configurationRegistry.registerConfiguration({
type: 'string',
enum: ['auto', 'true', 'false'],
markdownEnumDescriptions: [
nls.localize('notebook.scrolling.anchorToFocusedCell.auto.description', "Anchor to the focused cell unless {0} is set to {1}", 'notebook.scrolling.revealCellBehavior', 'none')
nls.localize('notebook.scrolling.anchorToFocusedCell.auto.description', "Anchor to the focused cell when the resized cell is partially visible unless {0} is set to {1}", 'notebook.scrolling.revealCellBehavior', 'none')
],
default: 'auto'
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2384,6 +2384,8 @@ export class NotebookEditorWidget extends Disposable implements INotebookEditorD
this.revealInView(cell);
} else if (options?.revealBehavior === ScrollToRevealBehavior.firstLine) {
this.revealFirstLineIfOutsideViewport(cell);
} else if (options?.revealBehavior === ScrollToRevealBehavior.fullCell) {
this.revealInView(cell);
} else {
this.revealInCenterIfOutsideViewport(cell);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1205,10 +1205,14 @@ export class NotebookCellList extends WorkbenchList<CellViewModel> implements ID
const focused = this.getFocus();
const focus = focused.length ? focused[0] : null;

if (this.view.elementTop(index) >= this.view.getScrollTop()) {
return this.view.updateElementHeight(index, size, index);
}

const anchorFocusedSetting = this.configurationService.getValue(NotebookSetting.anchorToFocusedCell);
const allowScrolling = this.configurationService.getValue(NotebookSetting.scrollToRevealCell) !== 'none';
const anchorToFocusedCell = anchorFocusedSetting === 'true' || (allowScrolling && anchorFocusedSetting !== 'false');
if (focused && anchorToFocusedCell) {
const scrollHeuristic = allowScrolling && anchorFocusedSetting === 'auto' && this.view.elementTop(index) < this.view.getScrollTop();
if (focused && (anchorFocusedSetting === 'true' || scrollHeuristic)) {
this.view.updateElementHeight(index, size, focus);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@
import * as assert from 'assert';
import { DisposableStore } from 'vs/base/common/lifecycle';
import { ensureNoDisposablesAreLeakedInTestSuite } from 'vs/base/test/common/utils';
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
import { TestConfigurationService } from 'vs/platform/configuration/test/common/testConfigurationService';
import { TestInstantiationService } from 'vs/platform/instantiation/test/common/instantiationServiceMock';
import { CellKind } from 'vs/workbench/contrib/notebook/common/notebookCommon';
import { CellKind, NotebookSetting } from 'vs/workbench/contrib/notebook/common/notebookCommon';
import { createNotebookCellList, setupInstantiationService, withTestNotebook } from 'vs/workbench/contrib/notebook/test/browser/testNotebookEditor';

suite('NotebookCellList', () => {
Expand All @@ -23,6 +25,10 @@ suite('NotebookCellList', () => {
setup(() => {
testDisposables = new DisposableStore();
instantiationService = setupInstantiationService(testDisposables);
const config = new TestConfigurationService({
[NotebookSetting.anchorToFocusedCell]: 'auto'
});
instantiationService.stub(IConfigurationService, config);
});

test('revealElementsInView: reveal fully visible cell should not scroll', async function () {
Expand Down