Look in all panes for existing preview to show

Previously only the next pane was checked for an existing
preview which would fail to locate any existing previews
that were moved to different panes or were no longer in the
next pane for the edit session.
This commit is contained in:
Kevin Sawicki
2013-04-09 08:47:38 -07:00
parent f1c9d09fd9
commit b2cb527f03

View File

@@ -15,12 +15,19 @@ module.exports =
console.warn("Can not render markdown for '#{editSession.getUri() ? 'untitled'}'")
return
if nextPane = activePane.getNextPane()
if preview = nextPane.itemForUri("markdown-preview:#{editSession.getPath()}")
nextPane.showItem(preview)
preview.fetchRenderedMarkdown()
else
nextPane.showItem(new MarkdownPreviewView(editSession.buffer))
{previewPane, previewItem} = @getExistingPreview(editSession)
if previewItem?
previewPane.showItem(previewItem)
previewItem.fetchRenderedMarkdown()
else if nextPane = activePane.getNextPane()
nextPane.showItem(new MarkdownPreviewView(editSession.buffer))
else
activePane.splitRight(new MarkdownPreviewView(editSession.buffer))
activePane.focus()
getExistingPreview: (editSession) ->
uri = "markdown-preview:#{editSession.getPath()}"
for previewPane in rootView.getPanes()
previewItem = previewPane.itemForUri(uri)
return {previewPane, previewItem} if previewItem?
{}