diff --git a/autoload/rst.vim b/autoload/rst.vim index 7737b94..0a90ae8 100644 --- a/autoload/rst.vim +++ b/autoload/rst.vim @@ -195,6 +195,7 @@ endfunc " - `anonymous link`__ " - namedlink_ " - `named link with spaces`_ +" - `named link with `_ " - naked urls func! rst#gx() abort " URL regexes @@ -253,16 +254,17 @@ func! rst#gx() abort " ... " `Google search`_ " .. _Yandex: https://yandex.ru + " + " angle brackets `exits through with-statements `_. + " + ".. _issue 1270: https://github.com/nedbat/coveragepy/issues/1270 try let save_view = winsaveview() let url_start = '\%(^\|[[:space:][\]()"' . "'" . '-:/]\)\zs`\ze[^`[:space:]]' let url_end = '\S\zs`_\ze\%($\|[[:space:].,:;!?"' . "." . '/\\>)\]}]\)' let url_name = '' - if expand("") =~ '^.*[^_]_$' - let url_name = expand("")[:-2] - endif if empty(url_name) - if getline('.')[col('.') - 2:] =~ '`_' + if col('.') > 2 && getline('.')[col('.') - 2 : col('.') + 2] =~ '`_' normal! 2h endif if searchpair(url_start, '', url_end, 'cbW') > 0 @@ -275,6 +277,12 @@ func! rst#gx() abort let url_name = getline(line('.') - 1)[s_pos[2] : ] let url_name .= ' ' . getline('.')[: e_pos[2] - 2] endif + " Check for angle brackets `exits through with-statements `_ + " and use it instead + let url_sub_name = matchstr(url_name, '<\zs.\{-}[^_]\ze_>') + if !empty(url_sub_name) + let url_name = url_sub_name + endif let url_name = substitute(url_name, '\s\+', '\\s\\+', 'g') endif endif @@ -287,6 +295,9 @@ func! rst#gx() abort endif endif endif + if empty(url_name) && expand("") =~ '^.*[^_]_$' + let url_name = expand("")[:-2] + endif finally call winrestview(save_view) endtry