Skip to content

Commit

Permalink
Oops
Browse files Browse the repository at this point in the history
  • Loading branch information
Don Jayamanne committed May 17, 2019
1 parent ed77d4d commit 627aeb7
Showing 1 changed file with 66 additions and 66 deletions.
132 changes: 66 additions & 66 deletions src/datascience-ui/history-react/MainPanel.tsx
Expand Up @@ -40,7 +40,7 @@ export class MainPanel extends React.Component<IMainPanelProps, IMainPanelState>
private updateCount = 0;
private renderCount = 0;
private editCellRef: Cell | null = null;
private mainPanel: HTMLDivElement | null = null;<<
private mainPanel: HTMLDivElement | null = null;
private variableExplorerRef: React.RefObject<VariableExplorer>;
private styleInjectorRef: React.RefObject<StyleInjector>;
private currentExecutionCount: number = 0;
Expand All @@ -59,7 +59,7 @@ export class MainPanel extends React.Component<IMainPanelProps, IMainPanelState>
cellVMs: [],
busy: true,
undoStack: [],
redoStack : [],
redoStack: [],
submittedText: false,
history: new InputHistory(),
contentTop: 24,
Expand All @@ -85,7 +85,7 @@ export class MainPanel extends React.Component<IMainPanelProps, IMainPanelState>
if (this.props.skipDefault) {
if (this.props.testMode) {
// Running a test, skip the tokenizer. We want the UI to display synchronously
this.state = {tokenizerLoaded: true, ...this.state};
this.state = { tokenizerLoaded: true, ...this.state };

// However we still need to register python as a language
registerMonacoLanguage();
Expand Down Expand Up @@ -200,13 +200,13 @@ export class MainPanel extends React.Component<IMainPanelProps, IMainPanelState>

case HistoryMessages.StartProgress:
if (!this.props.testMode) {
this.setState({busy: true});
this.setState({ busy: true });
}
break;

case HistoryMessages.StopProgress:
if (!this.props.testMode) {
this.setState({busy: false});
this.setState({ busy: false });
}
break;

Expand Down Expand Up @@ -318,7 +318,7 @@ export class MainPanel extends React.Component<IMainPanelProps, IMainPanelState>
);
}

private computeEditorOptions() : monacoEditor.editor.IEditorOptions {
private computeEditorOptions(): monacoEditor.editor.IEditorOptions {
const intellisenseOptions = getSettings().intellisenseOptions;
if (intellisenseOptions) {
return {
Expand Down Expand Up @@ -347,7 +347,7 @@ export class MainPanel extends React.Component<IMainPanelProps, IMainPanelState>

// Called by the header control when size changes (such as expanding variables)
private onHeaderHeightChange = (newHeight: number) => {
this.setState({contentTop: newHeight});
this.setState({ contentTop: newHeight });
}

private darkChanged = (newDark: boolean) => {
Expand Down Expand Up @@ -408,31 +408,31 @@ export class MainPanel extends React.Component<IMainPanelProps, IMainPanelState>
};
}
private getHeaderProps = (baseTheme: string): IHeaderPanelProps => {
return {
addMarkdown: this.addMarkdown,
busy: this.state.busy,
collapseAll: this.collapseAll,
expandAll: this.expandAll,
export: this.export,
restartKernel: this.restartKernel,
interruptKernel: this.interruptKernel,
undo: this.undo,
redo: this.redo,
clearAll: this.clearAll,
skipDefault: this.props.skipDefault,
showDataExplorer: this.showDataViewer,
testMode: this.props.testMode,
variableExplorerRef: this.variableExplorerRef,
canCollapseAll: this.canCollapseAll(),
canExpandAll: this.canExpandAll(),
canExport: this.canExport(),
canUndo: this.canUndo(),
canRedo: this.canRedo(),
refreshVariables: this.refreshVariables,
variableExplorerToggled: this.variableExplorerToggled,
onHeightChange: this.onHeaderHeightChange,
baseTheme: baseTheme
};
return {
addMarkdown: this.addMarkdown,
busy: this.state.busy,
collapseAll: this.collapseAll,
expandAll: this.expandAll,
export: this.export,
restartKernel: this.restartKernel,
interruptKernel: this.interruptKernel,
undo: this.undo,
redo: this.redo,
clearAll: this.clearAll,
skipDefault: this.props.skipDefault,
showDataExplorer: this.showDataViewer,
testMode: this.props.testMode,
variableExplorerRef: this.variableExplorerRef,
canCollapseAll: this.canCollapseAll(),
canExpandAll: this.canExpandAll(),
canExport: this.canExport(),
canUndo: this.canUndo(),
canRedo: this.canRedo(),
refreshVariables: this.refreshVariables,
variableExplorerToggled: this.variableExplorerToggled,
onHeightChange: this.onHeaderHeightChange,
baseTheme: baseTheme
};
}

private activate() {
Expand All @@ -442,7 +442,7 @@ export class MainPanel extends React.Component<IMainPanelProps, IMainPanelState>
setTimeout(() => {
// First we have to give ourselves focus (so that focus actually ends up in the code cell)
if (this.mainPanel) {
this.mainPanel.focus({preventScroll: true});
this.mainPanel.focus({ preventScroll: true });
}

if (this.editCellRef) {
Expand Down Expand Up @@ -482,7 +482,7 @@ export class MainPanel extends React.Component<IMainPanelProps, IMainPanelState>

private getAllCells = () => {
// Send all of our cells back to the other side
const cells = this.state.cellVMs.map((cellVM : ICellViewModel) => {
const cells = this.state.cellVMs.map((cellVM: ICellViewModel) => {
return cellVM.cell;
});

Expand All @@ -495,7 +495,7 @@ export class MainPanel extends React.Component<IMainPanelProps, IMainPanelState>

private addMarkdown = () => {
this.addCell({
data : {
data: {
cell_type: 'markdown',
metadata: {},
source: [
Expand All @@ -505,14 +505,14 @@ export class MainPanel extends React.Component<IMainPanelProps, IMainPanelState>
'- Of Items'
]
},
id : '1111',
file : 'foo.py',
line : 0,
state : CellState.finished
id: '1111',
file: 'foo.py',
line: 0,
state: CellState.finished
});
}

private getNonEditCellVMs() : ICellViewModel [] {
private getNonEditCellVMs(): ICellViewModel[] {
return this.state.cellVMs.filter(c => !c.editable);
}

Expand All @@ -529,14 +529,14 @@ export class MainPanel extends React.Component<IMainPanelProps, IMainPanelState>
}

private canRedo = () => {
return this.state.redoStack.length > 0 ;
return this.state.redoStack.length > 0;
}

private canUndo = () => {
return this.state.undoStack.length > 0 ;
return this.state.undoStack.length > 0;
}

private pushStack = (stack : ICellViewModel[][], cells : ICellViewModel[]) => {
private pushStack = (stack: ICellViewModel[][], cells: ICellViewModel[]) => {
// Get the undo stack up to the maximum length
const slicedUndo = stack.slice(0, min([stack.length, this.stackLimit]));

Expand All @@ -549,22 +549,22 @@ export class MainPanel extends React.Component<IMainPanelProps, IMainPanelState>
const cellVM = this.state.cellVMs[index];

// Send a message to the other side to jump to a particular cell
this.sendMessage(HistoryMessages.GotoCodeCell, { file : cellVM.cell.file, line: cellVM.cell.line });
this.sendMessage(HistoryMessages.GotoCodeCell, { file: cellVM.cell.file, line: cellVM.cell.line });
}

private deleteCell = (index: number) => {
this.sendMessage(HistoryMessages.DeleteCell);
const cellVM = this.state.cellVMs[index];
if (cellVM) {
this.sendMessage(HistoryMessages.RemoveCell, {id: cellVM.cell.id});
this.sendMessage(HistoryMessages.RemoveCell, { id: cellVM.cell.id });
}

// Update our state
this.setState({
cellVMs: this.state.cellVMs.filter((_c : ICellViewModel, i: number) => {
cellVMs: this.state.cellVMs.filter((_c: ICellViewModel, i: number) => {
return i !== index;
}),
undoStack : this.pushStack(this.state.undoStack, this.state.cellVMs),
undoStack: this.pushStack(this.state.undoStack, this.state.cellVMs),
skipNextScroll: true
});
}
Expand All @@ -588,7 +588,7 @@ export class MainPanel extends React.Component<IMainPanelProps, IMainPanelState>
// Update our state
this.setState({
cellVMs: [],
undoStack : this.pushStack(this.state.undoStack, this.state.cellVMs),
undoStack: this.pushStack(this.state.undoStack, this.state.cellVMs),
skipNextScroll: true,
busy: false // No more progress on delete all
});
Expand Down Expand Up @@ -622,9 +622,9 @@ export class MainPanel extends React.Component<IMainPanelProps, IMainPanelState>
this.sendMessage(HistoryMessages.Undo);
this.setState({
cellVMs: cells,
undoStack : undoStack,
redoStack : redoStack,
skipNextScroll : true
undoStack: undoStack,
redoStack: redoStack,
skipNextScroll: true
});

// Tell other side, we changed our number of cells
Expand Down Expand Up @@ -679,7 +679,7 @@ export class MainPanel extends React.Component<IMainPanelProps, IMainPanelState>
}
}

private getEditCell() : ICellViewModel | undefined {
private getEditCell(): ICellViewModel | undefined {
return this.state.editCellVM;
}

Expand Down Expand Up @@ -739,7 +739,7 @@ export class MainPanel extends React.Component<IMainPanelProps, IMainPanelState>
return cellVM;
}

const newCellVM = {...cellVM};
const newCellVM = { ...cellVM };
if (cellVM.inputBlockShow !== visible) {
if (visible) {
// Show the cell, the rest of the function will add on correct collapse state
Expand Down Expand Up @@ -779,20 +779,20 @@ export class MainPanel extends React.Component<IMainPanelProps, IMainPanelState>
}

private sendInfo = () => {
const info : IHistoryInfo = {
const info: IHistoryInfo = {
cellCount: this.getNonEditCellVMs().length,
undoCount: this.state.undoStack.length,
redoCount: this.state.redoStack.length
};
this.sendMessage(HistoryMessages.SendInfo, info);
}

private updateOrAdd = (cell: ICell, allowAdd? : boolean) => {
const index = this.state.cellVMs.findIndex((c : ICellViewModel) => {
private updateOrAdd = (cell: ICell, allowAdd?: boolean) => {
const index = this.state.cellVMs.findIndex((c: ICellViewModel) => {
return c.cell.id === cell.id &&
c.cell.line === cell.line &&
c.cell.file === cell.file;
});
c.cell.line === cell.line &&
c.cell.file === cell.file;
});
if (index >= 0) {
// Update this cell
this.state.cellVMs[index].cell = cell;
Expand All @@ -810,7 +810,7 @@ export class MainPanel extends React.Component<IMainPanelProps, IMainPanelState>
}
}

private isCellSupported(cell: ICell) : boolean {
private isCellSupported(cell: ICell): boolean {
return !this.props.testMode || cell.data.cell_type !== 'sys_info';
}

Expand Down Expand Up @@ -859,7 +859,7 @@ export class MainPanel extends React.Component<IMainPanelProps, IMainPanelState>
return realCells && realCells.length > 0 ? parseInt(realCells[realCells.length - 1].cell.data.execution_count!.toString(), 10) : 0;
}

private getInputExecutionCount = (cellVMs: ICellViewModel[]) : number => {
private getInputExecutionCount = (cellVMs: ICellViewModel[]): number => {
return this.getCurrentExecutionCount(cellVMs) + 1;
}

Expand All @@ -872,7 +872,7 @@ export class MainPanel extends React.Component<IMainPanelProps, IMainPanelState>
editCell.cell.data.source = code;

// Change type to markdown if necessary
const split = code.splitLines({trim: false});
const split = code.splitLines({ trim: false });
const firstLine = split[0];
const matcher = new CellMatcher(getSettings());
if (matcher.isMarkdown(firstLine)) {
Expand All @@ -898,7 +898,7 @@ export class MainPanel extends React.Component<IMainPanelProps, IMainPanelState>
this.setState({
cellVMs: [...this.state.cellVMs, editCell],
editCellVM: createEditableCellVM(this.getInputExecutionCount(this.state.cellVMs)),
undoStack : this.pushStack(this.state.undoStack, this.state.cellVMs),
undoStack: this.pushStack(this.state.undoStack, this.state.cellVMs),
redoStack: this.state.redoStack,
skipNextScroll: false,
submittedText: true
Expand Down Expand Up @@ -992,7 +992,7 @@ export class MainPanel extends React.Component<IMainPanelProps, IMainPanelState>
this.monacoIdToCellId.set(monacoId, id);
}

private getCellId = (monacoId: string) : string => {
private getCellId = (monacoId: string): string => {
const result = this.monacoIdToCellId.get(monacoId);
if (result) {
return result;
Expand All @@ -1007,7 +1007,7 @@ export class MainPanel extends React.Component<IMainPanelProps, IMainPanelState>
this.setState({ tokenizerLoaded: true });
}

private loadOnigasm = () : Promise<ArrayBuffer> => {
private loadOnigasm = (): Promise<ArrayBuffer> => {
if (!this.onigasmPromise) {
this.onigasmPromise = createDeferred<ArrayBuffer>();
// Send our load onigasm request
Expand All @@ -1016,7 +1016,7 @@ export class MainPanel extends React.Component<IMainPanelProps, IMainPanelState>
return this.onigasmPromise.promise;
}

private loadTmlanguage = () : Promise<string> => {
private loadTmlanguage = (): Promise<string> => {
if (!this.tmlangugePromise) {
this.tmlangugePromise = createDeferred<string>();
// Send our load onigasm request
Expand Down

0 comments on commit 627aeb7

Please sign in to comment.