elm / elm-lang.org

Server and client code for the Elm website.
http://elm-lang.org/
BSD 3-Clause "New" or "Revised" License
1.99k stars 366 forks source link

Fix search in code editor #884

Open cben opened 1 year ago

cben commented 1 year ago

Search within code was broken on https://elm-lang.org/try and all examples :crying_cat_face:

  1. CodeMirror's builtin search bar was invisible => copied missing dialog.css from https://github.com/codemirror/codemirror5/blob/5.40.2/addon/dialog/dialog.css

    before after
    bildo bildo
  2. Switched CodeMirror's search to "findPersistent" which behaves closer to browser's search.

  3. Sometimes user will encounter browser's search anyway (if focus was outside editor, via menu, in Chrome on 2nd Ctrl-F press...).
    Tuned CodeMirror to keep up to 500 off-screen lines in DOM (default was 10), allowing browser's search to Just Work accurately on all elm examples.
    (not setting Infinity to avoid slow editor in case user pastes very long code. CM's builtin search is always accurate.)