mirror of
https://github.com/atom/atom.git
synced 2026-04-06 03:02:13 -04:00
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:
@@ -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?
|
||||
{}
|
||||
|
||||
Reference in New Issue
Block a user