mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 10:58:30 -05:00
Prevent Markdown Cells from Collapsing (#8317)
This commit is contained in:
@@ -108,6 +108,9 @@ export class CellModel implements ICellModel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public set isCollapsed(value: boolean) {
|
public set isCollapsed(value: boolean) {
|
||||||
|
if (this.cellType !== CellTypes.Code) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
let stateChanged = this._isCollapsed !== value;
|
let stateChanged = this._isCollapsed !== value;
|
||||||
this._isCollapsed = value;
|
this._isCollapsed = value;
|
||||||
|
|
||||||
@@ -603,7 +606,7 @@ export class CellModel implements ICellModel {
|
|||||||
this._source = this.getMultilineSource(cell.source);
|
this._source = this.getMultilineSource(cell.source);
|
||||||
this._metadata = cell.metadata || {};
|
this._metadata = cell.metadata || {};
|
||||||
|
|
||||||
if (this._metadata.tags && this._metadata.tags.some(x => x === HideInputTag)) {
|
if (this._metadata.tags && this._metadata.tags.some(x => x === HideInputTag) && this._cellType === CellTypes.Code) {
|
||||||
this._isCollapsed = true;
|
this._isCollapsed = true;
|
||||||
} else {
|
} else {
|
||||||
this._isCollapsed = false;
|
this._isCollapsed = false;
|
||||||
|
|||||||
@@ -335,6 +335,34 @@ suite('Cell Model', function (): void {
|
|||||||
assert(!isCollapsed);
|
assert(!isCollapsed);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('Should not allow markdown cells to be collapsible', async function (): Promise<void> {
|
||||||
|
let mdCellData: nb.ICellContents = {
|
||||||
|
cell_type: CellTypes.Markdown,
|
||||||
|
source: 'some *markdown*',
|
||||||
|
outputs: [],
|
||||||
|
metadata: { language: 'python' }
|
||||||
|
};
|
||||||
|
let cell = factory.createCell(mdCellData, undefined);
|
||||||
|
assert(cell.isCollapsed === false);
|
||||||
|
cell.isCollapsed = true;
|
||||||
|
// The typescript compiler will complain if we don't ignore the error from the following line,
|
||||||
|
// claiming that cell.isCollapsed will return true. It doesn't.
|
||||||
|
// @ts-ignore
|
||||||
|
assert(cell.isCollapsed === false);
|
||||||
|
|
||||||
|
let codeCellData: nb.ICellContents = {
|
||||||
|
cell_type: CellTypes.Code,
|
||||||
|
source: '1+1',
|
||||||
|
outputs: [],
|
||||||
|
metadata: { language: 'python' },
|
||||||
|
execution_count: 1
|
||||||
|
};
|
||||||
|
cell = factory.createCell(codeCellData, undefined);
|
||||||
|
assert(cell.isCollapsed === false);
|
||||||
|
cell.isCollapsed = true;
|
||||||
|
assert(cell.isCollapsed === true);
|
||||||
|
});
|
||||||
|
|
||||||
suite('Model Future handling', function (): void {
|
suite('Model Future handling', function (): void {
|
||||||
let future: TypeMoq.Mock<EmptyFuture>;
|
let future: TypeMoq.Mock<EmptyFuture>;
|
||||||
let cell: ICellModel;
|
let cell: ICellModel;
|
||||||
|
|||||||
Reference in New Issue
Block a user