import { ApplicationState } from '../../../shared/models/applicationState';
import { defineAction } from '../../reduxWithLessSux/action';

export const closeActiveProjectFile = defineAction(
	'closeActiveProjectFile', (state: ApplicationState) => {
		const editors = state.editors.filter((_, editorIndex) => editorIndex !== state.activeEditorIndex);
		return {
			...state,
			editors
		};
	}
).getDispatcher();

import { ApplicationState } from '../../../shared/models/applicationState';
import { defineAction } from '../../reduxWithLessSux/action';

export const closeActiveProjectFile = defineAction(
	'closeActiveProjectFile', (state: ApplicationState) => {
		let { activeEditorIndex } = state;
		const editors = state.editors.filter((_, editorIndex) => editorIndex !== activeEditorIndex);
		activeEditorIndex = editors.length - 1;
		return {
			...state,
			activeEditorIndex,
			editors
		};
	}
).getDispatcher();

Fix bug where closing a file could result in a completely blank ui
Fix bug where closing a file could result in a completely blank ui

