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

Convert to switch/case

This makes the logic more clear
上级 8b72fdc3
......@@ -755,8 +755,14 @@ var requirejs = (function() {
return;
}
if (data.__vscode_notebook_message) {
if (data.type === 'dimension') {
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;
......@@ -770,7 +776,10 @@ var requirejs = (function() {
const cellId = data.id.substr(0, data.id.length - '_preview'.length);
this.notebookEditor.updateMarkdownCellHeight(cellId, data.data.height, !!data.init);
}
} else if (data.type === 'mouseenter') {
break;
}
case 'mouseenter':
{
const resolvedResult = this.resolveOutputId(data.id);
if (resolvedResult) {
const latestCell = this.notebookEditor.getCellByInfo(resolvedResult.cellInfo);
......@@ -778,7 +787,10 @@ var requirejs = (function() {
latestCell.outputIsHovered = true;
}
}
} else if (data.type === 'mouseleave') {
break;
}
case 'mouseleave':
{
const resolvedResult = this.resolveOutputId(data.id);
if (resolvedResult) {
const latestCell = this.notebookEditor.getCellByInfo(resolvedResult.cellInfo);
......@@ -786,17 +798,26 @@ var requirejs = (function() {
latestCell.outputIsHovered = false;
}
}
} else if (data.type === 'scroll-ack') {
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());
} else if (data.type === 'did-scroll-wheel') {
break;
}
case 'did-scroll-wheel':
{
this.notebookEditor.triggerScroll({
...data.payload,
preventDefault: () => { },
stopPropagation: () => { }
});
} else if (data.type === 'focus-editor') {
break;
}
case 'focus-editor':
{
const resolvedResult = this.resolveOutputId(data.id);
if (resolvedResult) {
const latestCell = this.notebookEditor.getCellByInfo(resolvedResult.cellInfo);
......@@ -810,42 +831,68 @@ var requirejs = (function() {
this.notebookEditor.focusNotebookCell(latestCell, 'editor');
}
}
} else if (data.type === 'clicked-data-url') {
break;
}
case 'clicked-data-url':
{
this._onDidClickDataLink(data);
} else if (data.type === 'customRendererMessage') {
break;
}
case 'customRendererMessage':
{
this._onMessage.fire({ message: data.message, forRenderer: data.rendererId });
} else if (data.type === 'focusMarkdownPreview') {
break;
}
case 'focusMarkdownPreview':
{
const cell = this.notebookEditor.getCellById(data.cellId);
if (cell) {
this.notebookEditor.focusNotebookCell(cell, 'container');
}
} else if (data.type === 'toggleMarkdownPreview') {
break;
}
case 'toggleMarkdownPreview':
{
this.notebookEditor.setMarkdownCellEditState(data.cellId, CellEditState.Editing);
} else if (data.type === 'mouseEnterMarkdownPreview') {
break;
}
case 'mouseEnterMarkdownPreview':
{
const cell = this.notebookEditor.getCellById(data.cellId);
if (cell instanceof MarkdownCellViewModel) {
cell.cellIsHovered = true;
}
} else if (data.type === 'mouseLeaveMarkdownPreview') {
break;
}
case 'mouseLeaveMarkdownPreview':
{
const cell = this.notebookEditor.getCellById(data.cellId);
if (cell instanceof MarkdownCellViewModel) {
cell.cellIsHovered = false;
}
} else if (data.type === 'cell-drag-start') {
break;
}
case 'cell-drag-start':
{
this.notebookEditor.markdownCellDragStart(data.cellId, data.position);
} else if (data.type === 'cell-drag') {
break;
}
case 'cell-drag':
{
this.notebookEditor.markdownCellDrag(data.cellId, data.position);
} else if (data.type === 'cell-drag-end') {
break;
}
case 'cell-drag-end':
{
this.notebookEditor.markdownCellDragEnd(data.cellId, {
clientY: data.position.clientY,
ctrlKey: data.ctrlKey,
altKey: data.altKey,
});
break;
}
return;
}
this._onMessage.fire({ message: data });
}));
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册