public void UpdateGherkinHighlighing(bool installFolding = true)
        {
            if (string.IsNullOrEmpty(CurrentFilePath) || (MainGherkinEditor == null))
            {
                return;
            }

            try
            {
                if (GherkinUtil.IsFeatureFile(CurrentFilePath))
                {
                    GherkinUtil.RegisterGherkinHighlighting(CurrentLanguage);
                    IHighlightingDefinition highlighting = GetHighlightingDefinition();
                    UpdateEditorProperty(nameof(GherkinEditor.SyntaxHighlighting), highlighting);

                    if (installFolding && (FoldingExecutor != null))
                    {
                        FoldingExecutor.InstallFoldingManager(CurrentFilePath);
                    }
                }
            }
            catch (Exception ex)
            {
                EventAggregator <StatusChangedArg> .Instance.Publish(this, new StatusChangedArg(ex.Message));
            }
        }
        public void UpdateFoldings(bool refresh)
        {
            if (FoldingExecutor == null)
            {
                return;
            }

            if (FoldingExecutor.IsCurrentFoldingFeature)
            {
                UpdateGherkinHighlighing();
                List <NewFolding> scenarioFoldings = FoldingExecutor.UpdateFeatureFoldings(IsCloseTablesFolding, IsCloseScenarioFolding, refresh);
                UpdateScenarioIndexes(scenarioFoldings);
            }
            else if (FoldingExecutor.IsCurrentFoldingXML)
            {
                FoldingExecutor.UpdateXMLFoldings();
            }
        }
        private void UpdateEditor(string filePath)
        {
            bool isOldFileFeatureFile = GherkinUtil.IsFeatureFile(Document.FileName);

            SetSyntaxHighlighting(filePath);
            FoldingExecutor?.InstallFoldingManager(filePath);
            CurrentFilePath   = filePath;
            Document.FileName = filePath;
            FileNameChangedEvent?.Invoke(filePath);
            if (isOldFileFeatureFile != IsFeatureFile)
            {
                HideScenarioIndex = !IsFeatureFile;
            }

            if (CurrentFilePath != filePath)
            {
                EventAggregator <FileSavedAsArg> .Instance.Publish(this, new FileSavedAsArg(CurrentFilePath));
            }
        }
        public void InitializeEditorView(TextEditor mainEditor, TextEditor subEditor, TextEditor viewerEditor)
        {
            TextDocument document = mainEditor.Document;

            MainGherkinEditor = new GherkinEditor(mainEditor, viewerEditor, document, m_AppSettings, FontFamily, FontSize, installElementGenerators: false);
            mainEditor.TextArea.IsKeyboardFocusedChanged += OnMainEditorKeyboardFocusedChanged;

            SubGherkinEditor = new GherkinEditor(subEditor, null /*viewerEditor*/, document, m_AppSettings, FontFamily, FontSize, installElementGenerators: false);
            subEditor.TextArea.IsKeyboardFocusedChanged += OnSubEditorKeyboardFocusedChanged;

            ViewerGherkinEditor = new GherkinEditor(viewerEditor, null /*viewerEditor*/, document, m_AppSettings, FontFamily, FontSize, installElementGenerators: true);
            viewerEditor.TextArea.IsKeyboardFocusedChanged += OnViewerEditorKeyboardFocusedChanged;

            FoldingExecutor = new FoldingExecutor(MainGherkinEditor, SubGherkinEditor, ViewerGherkinEditor);
            Load(CurrentFilePath);

            EventAggregator <EditorViewInitializationCompleted> .Instance.Publish(this, new EditorViewInitializationCompleted());

            TextEditorLoadedEvent?.Invoke();
            mainEditor.TextArea.Caret.PositionChanged   += OnMainEditorCaretPositionChanged;
            viewerEditor.TextArea.Caret.PositionChanged += OnViewerEditorCaretPositionChanged;
        }