Only show markdown preview if the edit session's grammar is GFM

This commit is contained in:
Corey Johnson
2013-03-25 13:29:12 -07:00
committed by probablycorey
parent e03f2fd738
commit 5f2c4dad95
2 changed files with 12 additions and 1 deletions

View File

@@ -15,6 +15,8 @@ module.exports =
return
editSession = item
return unless editSession.getGrammar().scopeName == "source.gfm"
if nextPane = activePane.getNextPane()
if preview = nextPane.itemForUri("markdown-preview:#{editSession.getPath()}")
nextPane.showItem(preview)

View File

@@ -4,6 +4,7 @@ MarkdownPreviewView = require 'markdown-preview/lib/markdown-preview-view'
describe "MarkdownPreview package", ->
beforeEach ->
window.loadPackage('gfm')
project.setPath(project.resolve('markdown'))
window.rootView = new RootView
atom.activatePackage("markdown-preview", immediate: true)
@@ -17,6 +18,14 @@ describe "MarkdownPreview package", ->
beforeEach ->
rootView.attachToDom()
describe "when the edit session does not use the GFM grammar", ->
it "does not show a markdown preview", ->
rootView.open()
expect(rootView.getPanes()).toHaveLength(1)
rootView.getActiveView().trigger 'markdown-preview:show'
expect(rootView.getPanes()).toHaveLength(1)
describe "when a preview item has not been created for the edit session's uri", ->
describe "when there is more than one pane", ->
it "shows a markdown preview for the current buffer on the next pane", ->
@@ -76,4 +85,4 @@ describe "MarkdownPreview package", ->
preview.fetchRenderedMarkdown.reset()
pane1.saveActiveItem = () ->
pane1.trigger("core:save")
expect(preview.fetchRenderedMarkdown).toHaveBeenCalled()
expect(preview.fetchRenderedMarkdown).toHaveBeenCalled()