mirror of
https://github.com/atom/atom.git
synced 2026-01-24 14:28:14 -05:00
Only show markdown preview if the edit session's grammar is GFM
This commit is contained in:
committed by
probablycorey
parent
e03f2fd738
commit
5f2c4dad95
@@ -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)
|
||||
|
||||
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user