atom/markdown-preview

The preview pane displays the wrong context menu inside code blocks

matippetts opened this issue · 1 comments

Prerequisites

  • Put an X between the brackets on this line if you have done all of the following: ...

Description

The wrong context menu is sometimes displayed by the Markdown Preview pane. The function highlightCodeBlocks in renderer.coffee renders preformatted HTML blocks by creating instances of TextEditor and inserting them into the DOM. However, these TextEditor instances are not managed as Pane items. Instead, Workspace.getActivePaneItem() returns an instance of MarkdownPreviewView. Consequently, Workspace.getActiveTextEditor() returns undefined to the menu-item handlers.

Steps to Reproduce

  1. Open a markdown file
  2. Create a code block or HTML <pre> element with some content
  3. Toggle Markdown-Preview
  4. In the preview pane, right-click inside the code block

Expected behavior: The .markdown-preview context-menu should be displayed.

Actual behavior: The atom-text-editor context-menu is displayed.

Reproduces how often: Always

Versions

atom --version apm --version OS release
Atom : 1.34.0
Electron: 2.0.16
Chrome : 61.0.3163.100
Node : 8.9.3
apm 2.1.3
npm 6.2.0
node 8.9.3 x64
atom 1.34.0
python 2.7.12
git 2.7.4
Linux Mint 18.3

Additional Information

  • I believe this defect was introduced by pull #544,
    "Always use the text editor to highlight code blocks".

  • An example, showing edit commands enabled in the preview pane: Screenshot

rsese commented

Thanks for the detailed report! Reproduce with 1.34.0 on macOS 10.12.6.

Context menu outside a code block:

menu-outside-code-block