提交 25d37c8f 编写于 作者: J Johannes Rieken

Merge branch 'master' into joh/outline

......@@ -87,5 +87,14 @@ function limitRanges(ranges: FoldingRange[], maxRanges: number) {
entries += n;
}
}
return ranges.filter((r, index) => (typeof nestingLevels[index] === 'number') && nestingLevels[index] < maxLevel);
let result = [];
for (let i = 0; i < ranges.length; i++) {
let level = nestingLevels[i];
if (typeof level === 'number') {
if (level < maxLevel || (level === maxLevel && entries++ < maxRanges)) {
result.push(ranges[i]);
}
}
}
return result;
}
......@@ -204,11 +204,11 @@ suite('HTML Folding', () => {
];
assertRanges(input, [r(0, 19), r(1, 18), r(2, 3), r(5, 11), r(6, 7), r(9, 10), r(13, 14), r(16, 17)], 'no limit', void 0);
assertRanges(input, [r(0, 19), r(1, 18), r(2, 3), r(5, 11), r(6, 7), r(9, 10), r(13, 14), r(16, 17)], 'limit 8', 8);
assertRanges(input, [r(0, 19), r(1, 18), r(2, 3), r(5, 11), r(13, 14), r(16, 17)], 'limit 7', 7);
assertRanges(input, [r(0, 19), r(1, 18), r(2, 3), r(5, 11), r(6, 7), r(13, 14), r(16, 17)], 'limit 7', 7);
assertRanges(input, [r(0, 19), r(1, 18), r(2, 3), r(5, 11), r(13, 14), r(16, 17)], 'limit 6', 6);
assertRanges(input, [r(0, 19), r(1, 18)], 'limit 5', 5);
assertRanges(input, [r(0, 19), r(1, 18)], 'limit 4', 4);
assertRanges(input, [r(0, 19), r(1, 18)], 'limit 3', 3);
assertRanges(input, [r(0, 19), r(1, 18), r(2, 3), r(5, 11), r(13, 14)], 'limit 5', 5);
assertRanges(input, [r(0, 19), r(1, 18), r(2, 3), r(5, 11)], 'limit 4', 4);
assertRanges(input, [r(0, 19), r(1, 18), r(2, 3)], 'limit 3', 3);
assertRanges(input, [r(0, 19), r(1, 18)], 'limit 2', 2);
assertRanges(input, [r(0, 19)], 'limit 1', 1);
});
......
......@@ -507,6 +507,7 @@ export class Item {
return child.doRefresh(recursive, true);
}));
} else {
this.mapEachChild(child => child.updateVisibility());
return WinJS.TPromise.as(null);
}
});
......@@ -522,13 +523,17 @@ export class Item {
private doRefresh(recursive: boolean, safe: boolean = false): WinJS.Promise {
this.doesHaveChildren = this.context.dataSource.hasChildren(this.context.tree, this.element);
this.height = this._getHeight();
this.setVisible(this._isVisible());
this.updateVisibility();
this._onDidRefresh.fire(this);
return this.refreshChildren(recursive, safe);
}
private updateVisibility(): void {
this.setVisible(this._isVisible());
}
public refresh(recursive: boolean): WinJS.Promise {
return this.doRefresh(recursive);
}
......
......@@ -1695,4 +1695,42 @@ suite('TreeModel - bugs', () => {
assert.equal(counter.count, 0);
});
});
test('collapsed resolved parent should also update all children visibility on refresh', async function () {
const counter = new EventCounter();
const dataModel = new DynamicModel();
let isSonVisible = true;
const filter: _.IFilter = {
isVisible(_, element) {
return element !== 'son' || isSonVisible;
}
};
const model = new TreeModel({ dataSource: dataModel, filter });
dataModel.addChild('root', 'father');
dataModel.addChild('father', 'son');
await model.setInput('root');
await model.expand('father');
let nav = model.getNavigator();
assert.equal(nav.next().id, 'father');
assert.equal(nav.next().id, 'son');
assert.equal(nav.next(), null);
await model.collapse('father');
isSonVisible = false;
await model.refresh(undefined, true);
await model.expand('father');
nav = model.getNavigator();
assert.equal(nav.next().id, 'father');
assert.equal(nav.next(), null);
counter.dispose();
model.dispose();
});
});
......@@ -163,7 +163,7 @@ export const selectionBackground = registerColor('selection.background', { light
export const textSeparatorForeground = registerColor('textSeparator.foreground', { light: '#0000002e', dark: '#ffffff2e', hc: Color.black }, nls.localize('textSeparatorForeground', "Color for text separators."));
export const textLinkForeground = registerColor('textLink.foreground', { light: '#4080D0', dark: '#4080D0', hc: '#4080D0' }, nls.localize('textLinkForeground', "Foreground color for links in text."));
export const textLinkActiveForeground = registerColor('textLink.activeForeground', { light: '#4080D0', dark: '#4080D0', hc: '#4080D0' }, nls.localize('textLinkActiveForeground', "Foreground color for active links in text."));
export const textLinkActiveForeground = registerColor('textLink.activeForeground', { light: '#4080D0', dark: '#4080D0', hc: '#4080D0' }, nls.localize('textLinkActiveForeground', "Foreground color for links in text when clicked on and on mouse hover."));
export const textPreformatForeground = registerColor('textPreformat.foreground', { light: '#A31515', dark: '#D7BA7D', hc: '#D7BA7D' }, nls.localize('textPreformatForeground', "Foreground color for preformatted text segments."));
export const textBlockQuoteBackground = registerColor('textBlockQuote.background', { light: '#7f7f7f1a', dark: '#7f7f7f1a', hc: null }, nls.localize('textBlockQuoteBackground', "Background color for block quotes in text."));
export const textBlockQuoteBorder = registerColor('textBlockQuote.border', { light: '#007acc80', dark: '#007acc80', hc: Color.white }, nls.localize('textBlockQuoteBorder', "Border color for block quotes in text."));
......@@ -218,7 +218,7 @@ export const badgeForeground = registerColor('badge.foreground', { dark: Color.w
export const scrollbarShadow = registerColor('scrollbar.shadow', { dark: '#000000', light: '#DDDDDD', hc: null }, nls.localize('scrollbarShadow', "Scrollbar shadow to indicate that the view is scrolled."));
export const scrollbarSliderBackground = registerColor('scrollbarSlider.background', { dark: Color.fromHex('#797979').transparent(0.4), light: Color.fromHex('#646464').transparent(0.4), hc: transparent(contrastBorder, 0.6) }, nls.localize('scrollbarSliderBackground', "Scrollbar slider background color."));
export const scrollbarSliderHoverBackground = registerColor('scrollbarSlider.hoverBackground', { dark: Color.fromHex('#646464').transparent(0.7), light: Color.fromHex('#646464').transparent(0.7), hc: transparent(contrastBorder, 0.8) }, nls.localize('scrollbarSliderHoverBackground', "Scrollbar slider background color when hovering."));
export const scrollbarSliderActiveBackground = registerColor('scrollbarSlider.activeBackground', { dark: Color.fromHex('#BFBFBF').transparent(0.4), light: Color.fromHex('#000000').transparent(0.6), hc: contrastBorder }, nls.localize('scrollbarSliderActiveBackground', "Scrollbar slider background color when active."));
export const scrollbarSliderActiveBackground = registerColor('scrollbarSlider.activeBackground', { dark: Color.fromHex('#BFBFBF').transparent(0.4), light: Color.fromHex('#000000').transparent(0.6), hc: contrastBorder }, nls.localize('scrollbarSliderActiveBackground', "Scrollbar slider background color when clicked on."));
export const progressBarBackground = registerColor('progressBar.background', { dark: Color.fromHex('#0E70C0'), light: Color.fromHex('#0E70C0'), hc: contrastBorder }, nls.localize('progressBarBackground', "Background color of the progress bar that can show for long running operations."));
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册