Marker is placed on the wrong line after page visibility change


#1

Currently, in firefox when you open the developer tools panel and debug a document in the debugger tab and try to apply a marker to a line it works just fine. Although if you switch tabs, changing the visibility of the debugger tab to hidden then go back to the debugger tab you will see that the lines viewed in the document are still the same, which is good. Although, when you go to add a marker on a line without scrolling or clicking anywhere in the codemirror editor, the marker will be applied to a line near the top, rather than what is displayed.

Here is the original issue that I am working on: https://github.com/devtools-html/debugger.html/issues/4852.

Here is a gif showing what was described.
https://user-images.githubusercontent.com/254562/36548013-2c8965d0-17bd-11e8-9d8f-bd6652b5e1df.gif

So far I have tried detecting when the change in visibility occurs and when the editor becomes revisable, calling a codeMirror.refresh(), and also signalling different codeMirror events such as “refresh”, “update”, and a few others with CodeMirror.signal(…). The only thing that has worked thus far is to get the scrollInfo which seems to correspond to that of what is seen in the browser and scroll to the respective line.

I was just wondering if anyone had any recommendations on what I should do next. Let me know if this should be opened as a issue in the github repo and I would love to help with implementing a solution.

UPDATES:

  • This is not an issue when running the debugger simply by itself as its own application not in the firefox panel. After looking at the signals sent out in each case upon a visibility change, it was found that only in the breaking case (the firefox panel) does the codeMirror editor fire a “refresh” signal.
  • After looking into where the refresh is sent from, it is sent from onResize --> setSize.

#2

Is it possible that there is asynchronous updating going on, causing the refresh call to happen before the actual layout update?


#3

Thanks for the input @marijn, you were right, and yes, the change in visibility is detected, and hence the refresh is executed before the actual layout is updated. I was just wondering if you had any suggestions on the best way to wait for codeMirror to finish updating. I was trying to go off the codeMirror signals with no success.


#4

refresh is synchronous, you don’t need to wait for it.


#5

Sorry I mean to say, how to know when the layout is finished updating, for instance, I see that no refresh signal is sent out after switching tabs but onResize() is sent out from forEachCodeMirror(f).


#6

That depends on the code that is causing the update—it’s not something CodeMirror can control.