-
Notifications
You must be signed in to change notification settings - Fork 358
open relative links on click in preview, fixes #85 #442
base: master
Are you sure you want to change the base?
Conversation
8ffaf56
to
fcae1a2
Compare
@50Wliu @as-cii are the CI failures anything to worry about? They look unrelated to this PR |
Yes, they are related to this PR. The changes you committed do not follow the style guidelines. |
Thanks for the pointers, hopefully my code will get past the linter this time. |
c610503
to
193c09d
Compare
Travis is passing now, not sure what is happening with the spec failures on windows. |
Windows is 💥 💣 💀. Don't worry about it. |
Also, this will most likely need some specs. |
Also, how should we handle the case when the relative link points to something that doesn't exist? Currently, my code just open an empty markdown preview and that's it. I'm pretty new to the javascript/atom ecosystem. I'll see what I can do with writing some specs. |
describe "when a relative path is clicked", ->
it "opens the link in a new pane", ->
preview.destroy()
preview.element.remove()
filePath = atom.project.getDirectories()[0].resolve('subdir/relpath1.md')
preview = new MarkdownPreviewView({filePath})
jasmine.attachToDOM(preview.element)
waitsForPromise ->
preview.renderMarkdown()
runs ->
atom.commands.dispatch preview.element, 'click'
runs ->
console.log(preview.element) I writing some tests, but do you have suggestions on how to simulate the clicking of the url? I want to check that it loads the other file. |
It looks like you're already simulating the click with As for dealing with nonexistent code paths, I would suggest either:
|
I am simulating a click, but I don't think I'm actually clicking on the link. Is that possible? I would like to see |
When clicking a link to a nonexistent destination, the notification could give the option to create a new file at the destination. |
The
|
Currently this will also open links to the local document's anchors as empty files. Anchor links should jump to the anchor in the preview. It looks like this could be implemented using
|
Based on sleuthing by @rscottfree and @brandoncurtis