atom / markdown-preview

📝 Markdown preview in Atom
MIT License
1.23k stars 358 forks source link

The preview pane displays the wrong context menu inside code blocks #555

Open matippetts opened 5 years ago

matippetts commented 5 years ago

Prerequisites

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

rsese commented 5 years ago

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