Jump to the selected fragment in editing mode
Dear developer, I suggest adding a function to jump to the selected text or image in edit mode. For example, the user selects text or an image, clicks "Edit" in the context menu, and in the opened edit mode, the program immediately jumps to the code of the selected text or image. It would be nice if the code of the selected text/image was highlighted in color in the code editor.
Totally backing this up, a lock view to see directly the corresponding md/preview is just what I need (appart from the toolbox)
this doesn't work ?
Implemented in #539 — thanks for the suggestion, and for asking for the highlight as well as the jump. That second half turned out to be the part that made it feel finished.
Selecting text or an image in the preview and choosing Edit now opens the editor scrolled to that fragment, with its source lines selected. Your example — select an image, choose Edit, land on the code for that image — lands on the image's own line rather than on the whole paragraph around it.
What it does with each kind of selection
| you did this | the editor opens on |
|---|---|
| selected some text | those lines |
| selected across several paragraphs | all of them, whichever direction you dragged |
| clicked an image and right-clicked it | the image's own line |
| right-clicked with nothing selected | the block under the pointer |
| already had the editor open in split view | jumps to the fragment; the layout does not move |
⌘E and the toolbar's edit button do the same thing, so you do not have to remember which way in carries you there.
The highlight
You asked for the code to be highlighted in colour. It is Monaco's own selection, in whatever colour your theme uses — which also means it disappears by itself on your next click or keystroke, rather than lingering after it has stopped being useful.
One honest limitation: the jump selects whole lines, not the exact span. That is not laziness — the renderer reports columns against a preprocessed copy of your document, so for a line like Math $a+b$ then  here. the image is reported 6 columns off. A column-precise highlight would silently point at the wrong text in any document containing maths, which is worse than selecting the line.
Two things your request uncovered
Testing this by hand turned up two older bugs in the same paths, fixed in the same PR:
- The outline's jump has always landed short in documents with front matter — 11 lines off in our own stress-test document. The renderer counts lines from the body, the editor counts them from the file, and nothing in between said so.
- ⌘E did nothing at all in split view, and meant something different from the "Edit" menu entry. They are one behaviour now.
So the feature you asked for also paid for two fixes nobody had reported. Thanks for the report.