@@ -131,12 +131,11 @@ bool document_manager::open_file(const wxString& path, bool add_to_recent) {
131131 if (text_ctrl != nullptr ) text_ctrl->SetFocus ();
132132 return true ;
133133 }
134- const parser_info* parser = find_parser_by_extension (wxFileName (path).GetExt ());
135- if (parser == nullptr ) {
136- parser = get_parser_for_unknown_file (path, config);
137- if (parser == nullptr ) return false ;
134+ const wxString extension = wxFileName (path).GetExt ();
135+ if (!is_parser_supported (extension)) {
136+ if (!ensure_parser_for_unknown_file (path, config)) return false ;
138137 }
139- if (!create_document_tab (path, parser, true , add_to_recent)) return false ;
138+ if (!create_document_tab (path, true , add_to_recent)) return false ;
140139 auto * const text_ctrl = get_active_text_ctrl ();
141140 if (text_ctrl != nullptr ) {
142141 text_ctrl->Bind (wxEVT_KEY_UP, &main_window::on_text_cursor_changed, &main_win);
@@ -146,8 +145,7 @@ bool document_manager::open_file(const wxString& path, bool add_to_recent) {
146145 return true ;
147146}
148147
149- bool document_manager::create_document_tab (const wxString& path, const parser_info* parser, bool set_focus, bool add_to_recent) {
150- if (parser == nullptr ) return false ;
148+ bool document_manager::create_document_tab (const wxString& path, bool set_focus, bool add_to_recent) {
151149 try {
152150 config.import_document_settings (path);
153151 const wxString forced_extension = config.get_document_format (path);
@@ -196,7 +194,6 @@ bool document_manager::create_document_tab(const wxString& path, const parser_in
196194 auto * tab_data = new document_tab;
197195 tab_data->session_doc = std::move (session_doc);
198196 tab_data->file_path = path;
199- tab_data->parser = parser;
200197 wxPanel* panel = create_tab_panel (tab_data->session_doc ->content , tab_data);
201198 tab_data->panel = panel;
202199 notebook->AddPage (panel, tab_data->session_doc ->get_title (), true );
@@ -274,11 +271,6 @@ wxTextCtrl* document_manager::get_active_text_ctrl() const {
274271 return tab != nullptr ? tab->text_ctrl : nullptr ;
275272}
276273
277- const parser_info* document_manager::get_active_parser () const {
278- const document_tab* tab = get_active_tab ();
279- return tab != nullptr ? tab->parser : nullptr ;
280- }
281-
282274int document_manager::get_tab_count () const {
283275 return static_cast <int >(notebook->GetPageCount ());
284276}
0 commit comments