-
Notifications
You must be signed in to change notification settings - Fork 163
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix bug that fails to display link in eldoc when url-hidding mode is enabled #674
Conversation
Could you show us the code which reproduces your issue or add unit tests ? |
The code that creates the issue is inside ((and (or (thing-at-point-looking-at markdown-regex-link-inline)
(thing-at-point-looking-at markdown-regex-link-reference))
(or markdown-hide-urls markdown-hide-markup))
(let* ((imagep (string-equal (match-string 1) "!"))
(edit-keys (markdown--substitute-command-keys
(if imagep
"\\[markdown-insert-image]"
"\\[markdown-insert-link]")))
(edit-str (propertize edit-keys 'face 'font-lock-constant-face))
(referencep (string-equal (match-string 5) "["))
(object (if referencep "reference" "URL")))
(format "Hidden %s (%s to edit): %s" object edit-str
(if referencep
(concat
(propertize "[" 'face 'markdown-markup-face)
(propertize (match-string-no-properties 6)
'face 'markdown-reference-face)
(propertize "]" 'face 'markdown-markup-face))
(propertize (match-string-no-properties 6)
'face 'markdown-url-face))))) The function call But there is another call by (edit-keys (markdown--substitute-command-keys
(if imagep
"\\[markdown-insert-image]"
"\\[markdown-insert-link]"))) which also performs regular expression matching. This call will clear the state produced by Therefore the latter call to In my patch, I put the call to |
Sorry I would like you to show us sample markdown text and minimal configuration to reproduce this issue. And could you tell us how to reproduce in detail, cursor position, commands etc ? |
Ah I see. For example, I created and open a markdown file Then run |
@taquangtrung Thanks for good explanation. I have merged your patch and added a unit test #675 |
@syohex: thanks for the update! |
Hi,
Description
Currently, when the
URL hiding
feature is enabled,markdown eldoc
always throws the erroreldoc error: (wrong-type-argument stringp nil)
when a cursor is put under the hidden URL.I investigated the code and see that the problem is due to the fact that the regular expression matching state performed by
(thing-at-point-looking-at markdown-regex-link-inline)
, which is used to get the URL, is cleared by the next call to(markdown--substitute-command-keys (if imagep "\\[markdown-insert-image]" "\\[markdown-insert-link]"))
.So, this PR will fix this bug by getting the URL information early, before the call to
markdown--substitute-command-keys
.Can anyone take a look and merge it if possible?
Thank you!
Related Issue
Type of Change
Checklist
make test
).