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();

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();

--- 
+++ 
@@ -3,9 +3,12 @@
 
 export const closeActiveProjectFile = defineAction(
 	'closeActiveProjectFile', (state: ApplicationState) => {
-		const editors = state.editors.filter((_, editorIndex) => editorIndex !== state.activeEditorIndex);
+		let { activeEditorIndex } = state;
+		const editors = state.editors.filter((_, editorIndex) => editorIndex !== activeEditorIndex);
+		activeEditorIndex = editors.length - 1;
 		return {
 			...state,
+			activeEditorIndex,
 			editors
 		};
 	}
Fix bug where closing a file could result in a completely blank ui

