microsoft / vscode

Visual Studio Code
https://code.visualstudio.com
MIT License
164.19k stars 29.29k forks source link

References are shown in a cell that does not have references #99354

Closed sandy081 closed 4 years ago

sandy081 commented 4 years ago

🐛 Markdown cell that does not has reference is revealed

Kapture 2020-06-04 at 12 22 18

jrieken commented 4 years ago

wait... cannot reproduce. @sandy081 are you on lastest of the GH issue extension?

sandy081 commented 4 years ago

Yeah I am on latest.. I think the step I missed to add is to have ### Performance cell in edit mode. Updated.

Edit - I am on v0.0.27

jrieken commented 4 years ago

Thanks. The cell (markdown) needs to be in edit mode and must be outside the viewport for this to happens. For some reason the wrong editor is then picked up.

jrieken commented 4 years ago

@rebornix It seems like something goes wrong in the editor (and this might actually the same as https://github.com/microsoft/vscode/issues/98172).

When I adding below 👇 log lines here

console.log('CELL:', cell.uri.toString(), cell.getText().substr(0, 100));
console.log('EDITOR:', editor.getModel()!.uri.toString(), editor.getModel()!.getValue().substr(0, 100));

it will print this, which makes me believe that initially the right editor is selected but somehow the models must change or so...

CELL: vscode-notebook-cell:/Users/jrieken/Code/_samples/devfest/foo/my-work.github-issues#0000006 $vscode $milestone is:closed assignee:@me label:feature-request -label:on-testplan -label:verificati
notebookEditorWidget.js:302 EDITOR: vscode-notebook-cell:/Users/jrieken/Code/_samples/devfest/foo/my-work.github-issues#0000006 $vscode $milestone is:closed assignee:@me label:feature-request -label:on-testplan -label:verificati
notebookEditorWidget.js:301 CELL: vscode-notebook-cell:/Users/jrieken/Code/_samples/devfest/foo/my-work.github-issues#0000008 $vscode $milestone is:closed assignee:@me label:feature-request -label:on-release-notes -label:*dupl
notebookEditorWidget.js:302 EDITOR: vscode-notebook-cell:/Users/jrieken/Code/_samples/devfest/foo/my-work.github-issues#0000008 $vscode $milestone is:closed assignee:@me label:feature-request -label:on-release-notes -label:*dupl
jrieken commented 4 years ago

Digging a little deeper, it seems to be coming from here (revealInCenterIfOutsideViewport) but somehow async, e.g first the cell code editor is selected and focused and after that the post scroll logic kicks in which makes the MD cell render, which in return realises that it is editable and questionably focuses itself.

Screenshot 2020-06-04 at 14 48 18
roblourens commented 4 years ago

Thanks for the investigation! Found simpler repro steps -

I see the issue

rebornix commented 4 years ago

looking into it and the root cause is the markdown cell in editing mode always steals focus, it focuses the monaco editor when it's in edit mode, which triggers the cell to be focused then. Adding a guard fixes this issue.

reavel* can be async indeed as the editor takes time to initialize, without the editor being fully initialized, we can reveal a specific line or position to the right position in the viewport. Will improve this in debt week. https://github.com/microsoft/vscode/issues/99385

I'm seeing more usage with notebook, together with more bug reports, thanks for it!

roblourens commented 4 years ago

@misolori are you verifying in master? This isn't in a build yet

miguelsolorio commented 4 years ago

@roblourens doh, my bad. I started testing this and saw this persisted so was writing up an issue. I assumed that because this didn't have the unreleased label that it was released (need to look for released label instead). Didn't even look at the commit time, my mistake.

roblourens commented 4 years ago

Pushed a different fix, but also filed https://github.com/microsoft/vscode/issues/99390 for some related issues. Right now if you scroll the focused element out of view, list keyboard shortcuts will not work and it may or may not get refocused properly when scrolling back in.

JacksonKearl commented 4 years ago

\closedWith 0b18106