Skip to content

Image stays broken when re-executing Markdown cell #151151

@texttheater

Description

@texttheater

Applies To

  • Notebooks (.ipynb files)
    Interactive Window and/or Cell Scripts (.py files with #%% markers)

What happened?

  1. Create a Markdown cell with an tag referring to a non-existing path, e.g. <img src="myimg.png">.
  2. Execute the cell. A "broken image" icon appears.
  3. Create the image at the specified path.
  4. Click the cell to edit. Re-execute it (without making any changes).

Expected result: the image is now shown.

Actual result: still shows a broken image icon. (The image is only shown after making a change to the cell itself.)

VS Code Version

1.67.2

Jupyter Extension Version

v2022.4.1021342353

Jupyter logs

No response

Coding Language and Runtime Version

Markdown

Language Extension Version (if applicable)

No response

Anaconda Version (if applicable)

No response

Running Jupyter locally or remotely?

Local

Activity

greazer

greazer commented on Jun 2, 2022

@greazer
Member

Markdown is vscode core.

added
help wantedIssues identified as good community contribution opportunities
good first issueIssues identified as good for first-time contributors
on Jun 9, 2022
danilhendrasr

danilhendrasr commented on Jun 11, 2022

@danilhendrasr

Can I take a shot at this?

IdoHartuv

IdoHartuv commented on Jun 13, 2022

@IdoHartuv

I noticed that if we do the opposite action - show the existing image, delete the file and re-execute the cell again when the image file does not exist - the results are the same. The image is still shown like before.
After refreshing the window, or after closing and reopening the .ipynb file tab, the cell is being updated.

Maybe it is related to some cache saved in the cell we can reset each time the cell is being executed.

Eliiia

Eliiia commented on Jun 14, 2022

@Eliiia

i'd love to try this as my first open source contribution, but i have no clue where to even start looking. if someone can point me to a file or even a directory that is used for the rendering of .ipynb markdown, itd be very appreciated!

mjbvz

mjbvz commented on Jun 15, 2022

@mjbvz
Collaborator

We have logic to not re-render unchanged markdown cells:

const sameContent = initialization.content === entry.content;

This is correct if the user presses esc to cancel the current edit. However if they press run / enter, perhaps we need to force a re-render

danilhendrasr

danilhendrasr commented on Jun 15, 2022

@danilhendrasr

Sorry @Eliiia, I know you're looking forward to your first open source contribution, but mind if I take this? Since I proposed to work on it first.

Eliiia

Eliiia commented on Jun 15, 2022

@Eliiia

@danilhendrasr absolutely, go ahead :)

danilhendrasr

danilhendrasr commented on Jun 21, 2022

@danilhendrasr

Sorry it took quite a while for an update, I'm new to vscode's code base so I need some time to understand parts of it.

However I'm still not sure how to approach this best. At the moment I'm thinking of creating a new command (probably notebook.cell.finishEdit) which fires when user presses ctrl+enter or click the menu, meanwhile leaving the notebook.cell.quitEdit command to only fire when user presses esc.

What do you think? @mjbvz

mjbvz

mjbvz commented on Jun 21, 2022

@mjbvz
Collaborator

@danilhendrasr One idea:

The cell's text model has an internal _versionId property (along with some ids and other fields)

Try checking to see if these change when the cell is executed (compared to being canceled). If they do, we can base re-rendering on when the version changes instead of when the text content itself changes

danilhendrasr

danilhendrasr commented on Jun 22, 2022

@danilhendrasr

It doesn't.

It seems that _versionId only get incremented every time there's a change to the cell content during edit mode (i.e. when user press a button on their keyboard) regardless of whether the end result of the edit is the same as the previous content or not.

It doesn't get incremented if the user edits the cell then immediately quit editing regardless of by hitting Esc or Ctrl+Enter.

yashdev9274

yashdev9274 commented on Aug 7, 2022

@yashdev9274

is this issue still open?

yashdev9274

yashdev9274 commented on Aug 7, 2022

@yashdev9274

can anyone tell me how can i help

danilhendrasr

danilhendrasr commented on Aug 8, 2022

@danilhendrasr

There's already a PR for this, see #155268, it's already on the August milestone.

yashdev9274

yashdev9274 commented on Aug 8, 2022

@yashdev9274

thank you @danilhendrasr for mentioning , are you working on any project currently which I can help to contribute
My tech stack is MERN stack and ML , please let me know .
I want to start my open source journey but I have no one to guide me , if you can guide me than I will be able to improve my developing skills with open source and can get a job

added this to the Backlog milestone on Dec 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugIssue identified by VS Code Team member as probable buggood first issueIssues identified as good for first-time contributorshelp wantedIssues identified as good community contribution opportunitiesnotebook

Type

No type

Projects

No projects

Relationships

None yet

    Development

    Participants

    @texttheater@rebornix@DonJayamanne@greazer@mjbvz

    Issue actions

      Image stays broken when re-executing Markdown cell · Issue #151151 · microsoft/vscode