@@ -105,54 +105,60 @@ for_href(const std::string& href)
105105 == CURLUE_OK)
106106 {
107107 auto path = std::filesystem::path{path_part.in ()};
108-
109- switch (detect_text_format (" " _frag, path)) {
110- case text_format_t ::TF_UNKNOWN:
111- case text_format_t ::TF_BINARY:
112- break ;
113- default : {
114- auto line = 0UL ;
115- auto col = 0UL ;
116-
117- auto_mem<char > frag_part (curl_free);
118- if (curl_url_get (cu,
119- CURLUPART_FRAGMENT,
120- frag_part.out (),
121- CURLU_URLDECODE)
122- == CURLUE_OK)
123- {
124- static const auto FRAG_RE
125- = lnav::pcre2pp::code::from_const (
126- R"( ^L(\d+)(?:C(\d+))?$)" );
127- thread_local auto match_data
128- = lnav::pcre2pp::match_data::unitialized ();
129- auto frag_sf = string_fragment::from_c_str (
130- frag_part.in ());
131-
132- log_debug (" checking fragment for position: %s" ,
133- frag_part.in ());
134- if (FRAG_RE.capture_from (frag_sf)
135- .into (match_data)
136- .found_p ())
108+ auto tf_opt = detect_text_format (" " _frag, path);
109+
110+ if (tf_opt.has_value ()) {
111+ switch (tf_opt.value ()) {
112+ case text_format_t ::TF_PLAINTEXT:
113+ case text_format_t ::TF_BINARY:
114+ break ;
115+ default : {
116+ auto line = 0UL ;
117+ auto col = 0UL ;
118+
119+ auto_mem<char > frag_part (curl_free);
120+ if (curl_url_get (cu,
121+ CURLUPART_FRAGMENT,
122+ frag_part.out (),
123+ CURLU_URLDECODE)
124+ == CURLUE_OK)
137125 {
138- line = scn::scan_int<uint32_t >(
139- match_data[1 ]->to_string_view ())
140- ->value ();
141- if (match_data[2 ]) {
142- col = scn::scan_int<uint32_t >(
143- match_data[2 ]
144- ->to_string_view ())
145- ->value ();
126+ static const auto FRAG_RE
127+ = lnav::pcre2pp::code::from_const (
128+ R"( ^L(\d+)(?:C(\d+))?$)" );
129+ thread_local auto match_data = lnav::
130+ pcre2pp::match_data::unitialized ();
131+ auto frag_sf = string_fragment::from_c_str (
132+ frag_part.in ());
133+
134+ log_debug (
135+ " checking fragment for position: %s" ,
136+ frag_part.in ());
137+ if (FRAG_RE.capture_from (frag_sf)
138+ .into (match_data)
139+ .found_p ())
140+ {
141+ line = scn::scan_int<uint32_t >(
142+ match_data[1 ]
143+ ->to_string_view ())
144+ ->value ();
145+ if (match_data[2 ]) {
146+ col = scn::scan_int<uint32_t >(
147+ match_data[2 ]
148+ ->to_string_view ())
149+ ->value ();
150+ }
146151 }
147152 }
153+ log_info (
154+ " Opening href with external editor: "
155+ " %s:%lu:%lu" ,
156+ path_part.in (),
157+ line,
158+ col);
159+ return external_editor::open (
160+ path_part.in (), line, col);
148161 }
149- log_info (
150- " Opening href with external editor: %s:%lu:%lu" ,
151- path_part.in (),
152- line,
153- col);
154- return external_editor::open (
155- path_part.in (), line, col);
156162 }
157163 }
158164 }
0 commit comments