private void OnDeleteEditorTab(object sender, DeleteEditorTabRequestedArg arg)
        {
            EditorTabContentViewModel editorViewModel = arg.EditorViewModel;
            MessageBoxResult          result          = GherkinSettings.SaveCurrentFileWithRequesting(editorViewModel);

            if (result == MessageBoxResult.Cancel)
            {
                return;
            }

            EventAggregator <EditorClosedArg> .Instance.Publish(this, new EditorClosedArg(editorViewModel.CurrentFilePath));

            if (TabPanels.Count == 1)
            {
                CurrentEditor?.ChangeToEmptyFile();
                NotifyCurrentFilePathChanged();
                base.OnPropertyChanged(nameof(IsShowScenarioIndexEnabled));
            }
            else
            {
                EditorTabItem editorTab            = TabPanels.FirstOrDefault(x => x.EditorTabContentViewModel == editorViewModel);
                int           index                = TabPanels.IndexOf(editorTab);
                bool          isDeletingCurrentTab = (index == SelectedTabIndex);
                if (isDeletingCurrentTab)
                {
                    // Force select a tab before removing tab.
                    // Note: property changed notification would not be raised if index is same as SelectedTabIndex.
                    // Therefore we select another tab at first and then select agian the indexed tab if index == SelectedTabIndex
                    int other_index = (index + 1) % TabPanels.Count;
                    SelectedTabIndex = other_index;
                }

                TabPanels.Remove(editorTab);

                if (isDeletingCurrentTab)
                {
                    SelectedTabIndex = Math.Min(index, TabPanels.Count - 1);
                }
            }
        }