Skip to content

Commit 7b5f74d

Browse files
authored
Merge branch 'main' into fix/improve-marker-placements
2 parents 83b639d + 3648e8f commit 7b5f74d

File tree

7 files changed

+58
-29
lines changed

7 files changed

+58
-29
lines changed

src/vs/workbench/api/test/browser/extHostTesting.test.ts

Lines changed: 39 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
import * as assert from 'assert';
77
import * as sinon from 'sinon';
8+
import { timeout } from 'vs/base/common/async';
89
import { VSBuffer } from 'vs/base/common/buffer';
910
import { CancellationTokenSource } from 'vs/base/common/cancellation';
1011
import { Event } from 'vs/base/common/event';
@@ -85,11 +86,14 @@ suite('ExtHost Testing', () => {
8586
const ds = ensureNoDisposablesAreLeakedInTestSuite();
8687

8788
let single: TestExtHostTestItemCollection;
89+
let resolveCalls: (string | undefined)[] = [];
8890
setup(() => {
91+
resolveCalls = [];
8992
single = ds.add(new TestExtHostTestItemCollection('ctrlId', 'root', {
9093
getDocument: () => undefined,
9194
} as Partial<ExtHostDocumentsAndEditors> as ExtHostDocumentsAndEditors));
9295
single.resolveHandler = item => {
96+
resolveCalls.push(item?.id);
9397
if (item === undefined) {
9498
const a = new TestItemImpl('ctrlId', 'id-a', 'a', URI.file('/'));
9599
a.canResolveChildren = true;
@@ -305,7 +309,7 @@ suite('ExtHost Testing', () => {
305309
assert.deepStrictEqual(single.collectDiff(), [
306310
{
307311
op: TestDiffOpType.Update,
308-
item: { extId: new TestId(['ctrlId', 'id-a']).toString(), expand: TestItemExpandState.Expanded, item: { label: 'Hello world' } },
312+
item: { extId: new TestId(['ctrlId', 'id-a']).toString(), item: { label: 'Hello world' } },
309313
},
310314
{
311315
op: TestDiffOpType.DocumentSynced,
@@ -326,6 +330,40 @@ suite('ExtHost Testing', () => {
326330
assert.deepStrictEqual(single.collectDiff(), []);
327331
});
328332

333+
suite('expandibility restoration', () => {
334+
const doReplace = async (canResolveChildren = true) => {
335+
const uri = single.root.children.get('id-a')!.uri;
336+
const newA = new TestItemImpl('ctrlId', 'id-a', 'Hello world', uri);
337+
newA.canResolveChildren = canResolveChildren;
338+
single.root.children.replace([
339+
newA,
340+
new TestItemImpl('ctrlId', 'id-b', single.root.children.get('id-b')!.label, uri),
341+
]);
342+
await timeout(0); // drain microtasks
343+
};
344+
345+
test('does not restore an unexpanded state', async () => {
346+
await single.expand(single.root.id, 0);
347+
assert.deepStrictEqual(resolveCalls, [undefined]);
348+
await doReplace();
349+
assert.deepStrictEqual(resolveCalls, [undefined]);
350+
});
351+
352+
test('restores resolve state on replacement', async () => {
353+
await single.expand(single.root.id, Infinity);
354+
assert.deepStrictEqual(resolveCalls, [undefined, 'id-a']);
355+
await doReplace();
356+
assert.deepStrictEqual(resolveCalls, [undefined, 'id-a', 'id-a']);
357+
});
358+
359+
test('does not expand if new child is not expandable', async () => {
360+
await single.expand(single.root.id, Infinity);
361+
assert.deepStrictEqual(resolveCalls, [undefined, 'id-a']);
362+
await doReplace(false);
363+
assert.deepStrictEqual(resolveCalls, [undefined, 'id-a']);
364+
});
365+
});
366+
329367
test('treats in-place replacement as mutation deeply', () => {
330368
single.expand(single.root.id, Infinity);
331369
single.collectDiff();
@@ -340,10 +378,6 @@ suite('ExtHost Testing', () => {
340378
single.root.children.replace([newA, single.root.children.get('id-b')!]);
341379

342380
assert.deepStrictEqual(single.collectDiff(), [
343-
{
344-
op: TestDiffOpType.Update,
345-
item: { extId: new TestId(['ctrlId', 'id-a']).toString(), expand: TestItemExpandState.Expanded },
346-
},
347381
{
348382
op: TestDiffOpType.Update,
349383
item: { extId: TestId.fromExtHostTestItem(oldAB, 'ctrlId').toString(), item: { label: 'Hello world' } },

src/vs/workbench/contrib/notebook/browser/notebook.contribution.ts

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1079,17 +1079,6 @@ configurationRegistry.registerConfiguration({
10791079
],
10801080
default: 'fullCell'
10811081
},
1082-
[NotebookSetting.anchorToFocusedCell]: {
1083-
markdownDescription: nls.localize('notebook.scrolling.anchorToFocusedCell.description', "Experimental. Keep the focused cell steady while surrounding cells change size."),
1084-
type: 'string',
1085-
enum: ['auto', 'on', 'off'],
1086-
markdownEnumDescriptions: [
1087-
nls.localize('notebook.scrolling.anchorToFocusedCell.auto.description', "Anchor the viewport to the focused cell depending on context unless {0} is set to {1}.", 'notebook.scrolling.revealCellBehavior', 'none'),
1088-
nls.localize('notebook.scrolling.anchorToFocusedCell.on.description', "Always anchor the viewport to the focused cell."),
1089-
nls.localize('notebook.scrolling.anchorToFocusedCell.off.description', "The focused cell may shift around as cells resize.")
1090-
],
1091-
default: 'auto'
1092-
},
10931082
[NotebookSetting.cellChat]: {
10941083
markdownDescription: nls.localize('notebook.cellChat', "Enable experimental floating chat widget in notebooks."),
10951084
type: 'boolean',

src/vs/workbench/contrib/notebook/browser/view/notebookCellAnchor.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,11 @@ export class NotebookCellAnchor implements IDisposable {
3838
const newFocusBottom = cellListView.elementTop(focusedIndex) + cellListView.elementHeight(focusedIndex) + heightDelta;
3939
const viewBottom = cellListView.renderHeight + cellListView.getScrollTop();
4040
const focusStillVisible = viewBottom > newFocusBottom;
41-
const anchorFocusedSetting = this.configurationService.getValue(NotebookSetting.anchorToFocusedCell);
4241
const allowScrolling = this.configurationService.getValue(NotebookSetting.scrollToRevealCell) !== 'none';
4342
const growing = heightDelta > 0;
44-
const autoAnchor = allowScrolling && growing && !focusStillVisible && anchorFocusedSetting !== 'off';
43+
const autoAnchor = allowScrolling && growing && !focusStillVisible;
4544

46-
if (autoAnchor || anchorFocusedSetting === 'on') {
45+
if (autoAnchor) {
4746
this.watchAchorDuringExecution(executingCellUri);
4847
return true;
4948
}

src/vs/workbench/contrib/notebook/common/notebookCommon.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -952,7 +952,6 @@ export const NotebookSetting = {
952952
outlineShowCodeCellSymbols: 'notebook.outline.showCodeCellSymbols',
953953
breadcrumbsShowCodeCells: 'notebook.breadcrumbs.showCodeCells',
954954
scrollToRevealCell: 'notebook.scrolling.revealNextCellOnExecute',
955-
anchorToFocusedCell: 'notebook.scrolling.experimental.anchorToFocusedCell',
956955
cellChat: 'notebook.experimental.cellChat',
957956
notebookVariablesView: 'notebook.experimental.variablesView',
958957
InteractiveWindowPromptToSave: 'interactiveWindow.promptToSaveOnClose',

src/vs/workbench/contrib/notebook/test/browser/notebookCellList.test.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,7 @@ suite('NotebookCellList', () => {
2626
setup(() => {
2727
testDisposables = new DisposableStore();
2828
instantiationService = setupInstantiationService(testDisposables);
29-
config = new TestConfigurationService({
30-
[NotebookSetting.anchorToFocusedCell]: 'auto'
31-
});
32-
29+
config = new TestConfigurationService();
3330
instantiationService.stub(IConfigurationService, config);
3431
});
3532

src/vs/workbench/contrib/notebook/test/browser/notebookViewZones.test.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import { TestConfigurationService } from 'vs/platform/configuration/test/common/
1212
import { TestInstantiationService } from 'vs/platform/instantiation/test/common/instantiationServiceMock';
1313
import { NotebookCellsLayout } from 'vs/workbench/contrib/notebook/browser/view/notebookCellListView';
1414
import { FoldingModel } from 'vs/workbench/contrib/notebook/browser/viewModel/foldingModel';
15-
import { CellEditType, CellKind, NotebookSetting } from 'vs/workbench/contrib/notebook/common/notebookCommon';
15+
import { CellEditType, CellKind } from 'vs/workbench/contrib/notebook/common/notebookCommon';
1616
import { createNotebookCellList, setupInstantiationService, withTestNotebook } from 'vs/workbench/contrib/notebook/test/browser/testNotebookEditor';
1717

1818
suite('NotebookRangeMap', () => {
@@ -339,10 +339,7 @@ suite('NotebookRangeMap with whitesspaces', () => {
339339
setup(() => {
340340
testDisposables = new DisposableStore();
341341
instantiationService = setupInstantiationService(testDisposables);
342-
config = new TestConfigurationService({
343-
[NotebookSetting.anchorToFocusedCell]: 'auto'
344-
});
345-
342+
config = new TestConfigurationService();
346343
instantiationService.stub(IConfigurationService, config);
347344
});
348345

src/vs/workbench/contrib/testing/common/testItemCollection.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -396,6 +396,7 @@ export class TestItemCollection<T extends ITestItemLike> extends Disposable {
396396
this.options.getApiFor(oldActual).listener = undefined;
397397

398398
internal.actual = actual;
399+
internal.resolveBarrier = undefined;
399400
internal.expand = TestItemExpandState.NotExpandable; // updated by `connectItemAndChildren`
400401

401402
if (update) {
@@ -416,6 +417,19 @@ export class TestItemCollection<T extends ITestItemLike> extends Disposable {
416417
}
417418
}
418419

420+
// Re-expand the element if it was previous expanded (#207574)
421+
const expandLevels = internal.expandLevels;
422+
if (expandLevels !== undefined) {
423+
// Wait until a microtask to allow the extension to finish setting up
424+
// properties of the element and children before we ask it to expand.
425+
queueMicrotask(() => {
426+
if (internal.expand === TestItemExpandState.Expandable) {
427+
internal.expandLevels = undefined;
428+
this.expand(fullId.toString(), expandLevels);
429+
}
430+
});
431+
}
432+
419433
// Mark ranges in the document as synced (#161320)
420434
this.documentSynced(internal.actual.uri);
421435
}

0 commit comments

Comments
 (0)