You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Sep 6, 2021. It is now read-only.
Repository navigation
This repository was archived by the owner on Sep 6, 2021. It is now read-only.
CodeMirror calculates incorrectly the min-height when the font size is not the default one #3115
While doing #3068 i noticed that every line not rendered (not in the dom) was calculated always using the default font size (15px) even when adjusting the font size. You can test this in different ways:
EditorManager.getCurrentFullEditor()._codeMirror.getLineHandle(0).height when the scroll is not at the top.
Get the top from the parent of .CodeMirror-lines with:
And the first rendered line with EditorManager.getCurrentFullEditor()._codeMirror.getViewport().from and then divide the top with the lines.
This is causing some the next visible problems:
Open a medium size file like ViewCommandHandlers.
Increase the font size a lot (10 times do the job).
Scroll down really fast using the the scroller thumb to make CodeMirror render a big part of the entire file at once, which would give a bigger height that what it was calculated and makes errors on the scrolling. Smaller font size would cause this problem too, but isn't as visible as with big ones.
Open Open src/thirdparty/CodeMirror2/lib/codemirror.js
Press Cmd/Ctrl-+ twice to increase font-size by 2 increments
Cmd-down (or Ctrl-End) to go to end of file
Check that even the first PageUp doesn't show the cursor inside the visible area and the cursor doesn't stay in the same position doing more PageUp/PageDown.
@TomMalbran -- could you take a stab at reproducing this in standalone CodeMirror (outside of Brackets)? I think the only thing CM is supposed to require after changing the font size is a refresh(), but we've noticed when looking at other previous issues that various bits of cached line height state don't all seem to get thrown out on a refresh. If you could reproduce this in CM and file it in the main CM repo, that would be very helpful. Thanks!
Also, could you characterize how bad the user-visible aspects of the bug are? If it's just that the cursor doesn't always end up visible after a page down, that's not terrible. But if you can't scroll to see the whole document, for example, that would be pretty bad.
I tested in a standalone CodeMirror and understood what is the problem: refresh() doesn't updates the min-height of the container, so things like PageUp from the bottom of the editor, or sometimes scrolling doesn't work as intended and keep modifying the min-height until it can get to the right size and fix everything.
Copied the whole content of codemirror.js and pasted it in the editor.
Opened the developer tools, selected the .CodeMirror div and checked the font size.
Selected the .CodeMirror-sizer div and checked the min-height.
Right now the min-height / amount of lines is similar to the font size.
Went back to the .CodeMirror div and increased the font size to 25px.
Used the console to refresh the editor with editor.refresh()
Checked in .CodeMirror-sizer div that the min-height didn't changed.
With the cursor at the last line, press PageUp multiple times and check how the min-height changes, until it gets to the start of the document and it has the right height.
It looks like the codemirror/codemirror5#2157 may have fixed this a couple months back. @TomMalbran are you still seeing this? Comments in #7093 would imply you still are..?
I haven't checked it in the code, but there is still something wrong. Open a file with over 300 lines and place the scroll at the top, increase the font size a bit and then scroll fast to the end of the file. You should see some issues with the scroll thumb which gets smaller as it reaches the end of the file.
Activity
njx commentedon Mar 18, 2013
@TomMalbran -- could you take a stab at reproducing this in standalone CodeMirror (outside of Brackets)? I think the only thing CM is supposed to require after changing the font size is a
refresh(), but we've noticed when looking at other previous issues that various bits of cached line height state don't all seem to get thrown out on a refresh. If you could reproduce this in CM and file it in the main CM repo, that would be very helpful. Thanks!njx commentedon Mar 18, 2013
Also, could you characterize how bad the user-visible aspects of the bug are? If it's just that the cursor doesn't always end up visible after a page down, that's not terrible. But if you can't scroll to see the whole document, for example, that would be pretty bad.
TomMalbran commentedon Mar 24, 2013
I tested in a standalone CodeMirror and understood what is the problem:
refresh()doesn't updates the min-height of the container, so things like PageUp from the bottom of the editor, or sometimes scrolling doesn't work as intended and keep modifying the min-height until it can get to the right size and fix everything.This is what I did:
codemirror.jsand pasted it in the editor..CodeMirrordiv and checked the font size..CodeMirror-sizerdiv and checked the min-height..CodeMirrordiv and increased the font size to 25px.editor.refresh().CodeMirror-sizerdiv that the min-height didn't changed.peterflynn commentedon Mar 7, 2014
It looks like the codemirror/codemirror5#2157 may have fixed this a couple months back. @TomMalbran are you still seeing this? Comments in #7093 would imply you still are..?
TomMalbran commentedon Mar 7, 2014
I haven't checked it in the code, but there is still something wrong. Open a file with over 300 lines and place the scroll at the top, increase the font size a bit and then scroll fast to the end of the file. You should see some issues with the scroll thumb which gets smaller as it reaches the end of the file.
TomMalbran commentedon Mar 7, 2014
It does seem to be fixed. I was testing in Sprint 36 before and not in master. I will test a bit more and close if it is fixed.
TomMalbran commentedon Mar 7, 2014
Cool, closing as fixed. Will submit a PR soon to remove the hack done to avoid this bug.