Page MenuHomePhabricator

CodeMirror option "viewportMargin: Infinity" rethinking
Open, Needs TriagePublic


As a solution to T174480, the extension sets the option "viewportMargin: Infinity" for the edit box. However, from the upstream side, this is not something CodeMirror developer recommends (reference). It could be particularly problematic for mobile browsers, such as T197502. There is also a recent desktop browser performance issue T303232, which shows a condition where the browser rendering can be notably slow on long articles. Therefore, I am going to reiterate some arguments from past discussion which were unfortunately declined, and to request a change back to a smaller viewportMargin.

The first argument comes from T174480#3566576. As a similar extension, CodeEditor does not support browser's native search while it provides a unique search UI and bind it to Ctrl-F. Actually, a unique search UI might be unnecessary because both CodeEditor and CodeMirror are compatible with jquery.textSelection. This means the WikiEditor search dialog works perfectly for them. I do not completely agree with the comment made in T174480#3574863 as a reason against this solution, because the WikiEditor search dialog is not only draggable but also resizable. These handy features make the dialog very flexible in the layout. Regarding the keypress "Enter" behavior, it can be easily modified if really necessary.

The second possibility is proposed in T174480#3578800 and committed in It seems promising to perform some kind of optimization like this. However, I am not familiar with performance testing, so I will leave it for other skilled developers to evaluate this approach.

I am new to this community, so please feel free to reopen T174480, for example, instead of this new task if that is the usual way to restart the discussion.

Event Timeline

Restricted Application added a subscriber: Aklapper. · View Herald Transcript

This is a nice write-up. Thanks for taking the time to create this task!

I agree seems like the best path forward. I have pinged TheDJ at T303232#7774521. If we don't hear back after a while I can try to revive the patch myself.

As for simply removing the viewportMargin: Infinity option entirely, I worry this will break too many workflows. Many people rely on Ctrl+F or use it from muscle memory. Even if it opens up the WikiEditor search dialog, I expect complaints. I think we should give TheDJ's solution another try first.

Note that this issue becomes invalid with CodeMirror 6 (T259059). The option viewportMargin: Infinity is no longer available in CodeMirror 6, and search keys were added as default extensions in T317243.