提交 d24ad98e 编写于 作者: M Matt Bierner

Convert to switch/case

This makes the logic more clear
上级 8b72fdc3
......@@ -755,97 +755,144 @@ var requirejs = (function() {
return;
}
if (data.__vscode_notebook_message) {
if (data.type === 'dimension') {
if (data.isOutput) {
const height = data.data.height;
const outputHeight = height;
if (!data.__vscode_notebook_message) {
this._onMessage.fire({ message: data });
return;
}
switch (data.type) {
case 'dimension':
{
if (data.isOutput) {
const height = data.data.height;
const outputHeight = height;
const resolvedResult = this.resolveOutputId(data.id);
if (resolvedResult) {
const { cellInfo, output } = resolvedResult;
this.notebookEditor.updateOutputHeight(cellInfo, output, outputHeight, !!data.init);
}
} else {
const cellId = data.id.substr(0, data.id.length - '_preview'.length);
this.notebookEditor.updateMarkdownCellHeight(cellId, data.data.height, !!data.init);
}
break;
}
case 'mouseenter':
{
const resolvedResult = this.resolveOutputId(data.id);
if (resolvedResult) {
const { cellInfo, output } = resolvedResult;
this.notebookEditor.updateOutputHeight(cellInfo, output, outputHeight, !!data.init);
const latestCell = this.notebookEditor.getCellByInfo(resolvedResult.cellInfo);
if (latestCell) {
latestCell.outputIsHovered = true;
}
}
} else {
const cellId = data.id.substr(0, data.id.length - '_preview'.length);
this.notebookEditor.updateMarkdownCellHeight(cellId, data.data.height, !!data.init);
break;
}
} else if (data.type === 'mouseenter') {
const resolvedResult = this.resolveOutputId(data.id);
if (resolvedResult) {
const latestCell = this.notebookEditor.getCellByInfo(resolvedResult.cellInfo);
if (latestCell) {
latestCell.outputIsHovered = true;
case 'mouseleave':
{
const resolvedResult = this.resolveOutputId(data.id);
if (resolvedResult) {
const latestCell = this.notebookEditor.getCellByInfo(resolvedResult.cellInfo);
if (latestCell) {
latestCell.outputIsHovered = false;
}
}
break;
}
case 'scroll-ack':
{
// const date = new Date();
// const top = data.data.top;
// console.log('ack top ', top, ' version: ', data.version, ' - ', date.getMinutes() + ':' + date.getSeconds() + ':' + date.getMilliseconds());
break;
}
case 'did-scroll-wheel':
{
this.notebookEditor.triggerScroll({
...data.payload,
preventDefault: () => { },
stopPropagation: () => { }
});
break;
}
} else if (data.type === 'mouseleave') {
const resolvedResult = this.resolveOutputId(data.id);
if (resolvedResult) {
const latestCell = this.notebookEditor.getCellByInfo(resolvedResult.cellInfo);
if (latestCell) {
latestCell.outputIsHovered = false;
case 'focus-editor':
{
const resolvedResult = this.resolveOutputId(data.id);
if (resolvedResult) {
const latestCell = this.notebookEditor.getCellByInfo(resolvedResult.cellInfo);
if (!latestCell) {
return;
}
if (data.focusNext) {
this.notebookEditor.focusNextNotebookCell(latestCell, 'editor');
} else {
this.notebookEditor.focusNotebookCell(latestCell, 'editor');
}
}
break;
}
} else if (data.type === 'scroll-ack') {
// const date = new Date();
// const top = data.data.top;
// console.log('ack top ', top, ' version: ', data.version, ' - ', date.getMinutes() + ':' + date.getSeconds() + ':' + date.getMilliseconds());
} else if (data.type === 'did-scroll-wheel') {
this.notebookEditor.triggerScroll({
...data.payload,
preventDefault: () => { },
stopPropagation: () => { }
});
} else if (data.type === 'focus-editor') {
const resolvedResult = this.resolveOutputId(data.id);
if (resolvedResult) {
const latestCell = this.notebookEditor.getCellByInfo(resolvedResult.cellInfo);
if (!latestCell) {
return;
case 'clicked-data-url':
{
this._onDidClickDataLink(data);
break;
}
case 'customRendererMessage':
{
this._onMessage.fire({ message: data.message, forRenderer: data.rendererId });
break;
}
case 'focusMarkdownPreview':
{
const cell = this.notebookEditor.getCellById(data.cellId);
if (cell) {
this.notebookEditor.focusNotebookCell(cell, 'container');
}
if (data.focusNext) {
this.notebookEditor.focusNextNotebookCell(latestCell, 'editor');
} else {
this.notebookEditor.focusNotebookCell(latestCell, 'editor');
break;
}
case 'toggleMarkdownPreview':
{
this.notebookEditor.setMarkdownCellEditState(data.cellId, CellEditState.Editing);
break;
}
case 'mouseEnterMarkdownPreview':
{
const cell = this.notebookEditor.getCellById(data.cellId);
if (cell instanceof MarkdownCellViewModel) {
cell.cellIsHovered = true;
}
break;
}
} else if (data.type === 'clicked-data-url') {
this._onDidClickDataLink(data);
} else if (data.type === 'customRendererMessage') {
this._onMessage.fire({ message: data.message, forRenderer: data.rendererId });
} else if (data.type === 'focusMarkdownPreview') {
const cell = this.notebookEditor.getCellById(data.cellId);
if (cell) {
this.notebookEditor.focusNotebookCell(cell, 'container');
case 'mouseLeaveMarkdownPreview':
{
const cell = this.notebookEditor.getCellById(data.cellId);
if (cell instanceof MarkdownCellViewModel) {
cell.cellIsHovered = false;
}
break;
}
} else if (data.type === 'toggleMarkdownPreview') {
this.notebookEditor.setMarkdownCellEditState(data.cellId, CellEditState.Editing);
} else if (data.type === 'mouseEnterMarkdownPreview') {
const cell = this.notebookEditor.getCellById(data.cellId);
if (cell instanceof MarkdownCellViewModel) {
cell.cellIsHovered = true;
case 'cell-drag-start':
{
this.notebookEditor.markdownCellDragStart(data.cellId, data.position);
break;
}
} else if (data.type === 'mouseLeaveMarkdownPreview') {
const cell = this.notebookEditor.getCellById(data.cellId);
if (cell instanceof MarkdownCellViewModel) {
cell.cellIsHovered = false;
case 'cell-drag':
{
this.notebookEditor.markdownCellDrag(data.cellId, data.position);
break;
}
case 'cell-drag-end':
{
this.notebookEditor.markdownCellDragEnd(data.cellId, {
clientY: data.position.clientY,
ctrlKey: data.ctrlKey,
altKey: data.altKey,
});
break;
}
} else if (data.type === 'cell-drag-start') {
this.notebookEditor.markdownCellDragStart(data.cellId, data.position);
} else if (data.type === 'cell-drag') {
this.notebookEditor.markdownCellDrag(data.cellId, data.position);
} else if (data.type === 'cell-drag-end') {
this.notebookEditor.markdownCellDragEnd(data.cellId, {
clientY: data.position.clientY,
ctrlKey: data.ctrlKey,
altKey: data.altKey,
});
}
return;
}
this._onMessage.fire({ message: data });
}));
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册