mirror of
https://github.com/Microsoft/vscode
synced 2024-09-19 18:48:00 +00:00
Convert to switch/case
This makes the logic more clear
This commit is contained in:
parent
8b72fdc3e9
commit
d24ad98e31
|
@ -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;
|
||||
|
||||
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);
|
||||
}
|
||||
} 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;
|
||||
}
|
||||
}
|
||||
} 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;
|
||||
}
|
||||
}
|
||||
} 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;
|
||||
}
|
||||
|
||||
if (data.focusNext) {
|
||||
this.notebookEditor.focusNextNotebookCell(latestCell, 'editor');
|
||||
} else {
|
||||
this.notebookEditor.focusNotebookCell(latestCell, 'editor');
|
||||
}
|
||||
}
|
||||
} 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');
|
||||
}
|
||||
} 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;
|
||||
}
|
||||
} else if (data.type === 'mouseLeaveMarkdownPreview') {
|
||||
const cell = this.notebookEditor.getCellById(data.cellId);
|
||||
if (cell instanceof MarkdownCellViewModel) {
|
||||
cell.cellIsHovered = false;
|
||||
}
|
||||
} 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,
|
||||
});
|
||||
}
|
||||
if (!data.__vscode_notebook_message) {
|
||||
this._onMessage.fire({ message: data });
|
||||
return;
|
||||
}
|
||||
|
||||
this._onMessage.fire({ message: data });
|
||||
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 latestCell = this.notebookEditor.getCellByInfo(resolvedResult.cellInfo);
|
||||
if (latestCell) {
|
||||
latestCell.outputIsHovered = true;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
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;
|
||||
}
|
||||
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;
|
||||
}
|
||||
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');
|
||||
}
|
||||
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;
|
||||
}
|
||||
case 'mouseLeaveMarkdownPreview':
|
||||
{
|
||||
const cell = this.notebookEditor.getCellById(data.cellId);
|
||||
if (cell instanceof MarkdownCellViewModel) {
|
||||
cell.cellIsHovered = false;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 'cell-drag-start':
|
||||
{
|
||||
this.notebookEditor.markdownCellDragStart(data.cellId, data.position);
|
||||
break;
|
||||
}
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
}));
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue