mkd.vim: open URL (gx) based on mkdID/mkdLinkDef #506
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This change lets
gx
open URLs when the cursor is on eithermkdID
,mkdLinkDef
syntax regions. It also supportsmkdLink
region where the following syntax region is amkdID
and not anmkdURL
. Indeed, the old setting is still preserved.FindNextSyntax
was repurposed for finding the next syntax object (whatever the name is). Then, we call repeatedly the function for getting where we want. Most of the time, we just need to call it twice or so.FindMkdLinkDefTargetPosition
,GetUrlPositionFromMkdLink
,GetUrlPositionFromMkdIDOrDef
: handle cases where we're presently looking at mkdLink, mkdID and mkdLinkDef.Markdown_GetUrlForPosition
: the approach was slightly changed so that we first find out if we're on a delimiter, then move from there to the delimited region. Then, we handle other cases seperatly from the delimiters case. This makes for an approach that is more readable and easier to maintain.This effectively fixes #382.
I don't know about people that expressed the issue #353, but the code seems to work OK before these changes according to the supported regions. May be the people from #353 will find a fix for their issue with this change if for some reason they didn't express their issue appropriately and that they were rather having an issue with
mkdID
andmkdLinkDef
not working. This was by design and consistent with the doc. However, it would be clearly more intuitive for the user if my change was merged. I may be misinterpreting. In the latter case, the issue is orthogonal to my change anyway.