Update markdown preview when markdown buffer is saved

This commit is contained in:
Mutwin Kraus
2013-03-21 16:16:56 +01:00
committed by probablycorey
parent 9a6b5986fe
commit 5c93fd4574
2 changed files with 14 additions and 0 deletions

View File

@@ -13,6 +13,8 @@ module.exports =
console.warn("Can not render markdown for #{item.getUri()}")
return
activePane.on 'core:save', => @show()
editSession = item
if nextPane = activePane.getNextPane()
if preview = nextPane.itemForUri("markdown-preview:#{editSession.getPath()}")

View File

@@ -65,3 +65,15 @@ describe "MarkdownPreview package", ->
expect(pane2.getItems()).toHaveLength 2
expect(pane2.activeItem).toBe preview
expect(pane1).toMatchSelector(':has(:focus)')
describe "when a buffer is modified and saved after a preview item has already been created", ->
it "updates the existing preview item", ->
rootView.getActiveView().trigger 'markdown-preview:show'
[pane1, pane2] = rootView.getPanes()
preview = pane2.activeItem
pane1.focus()
preview.fetchRenderedMarkdown.reset()
pane1.saveActiveItem = () ->
pane1.trigger("core:save")
expect(preview.fetchRenderedMarkdown).toHaveBeenCalled()