jcb91 / jupyter_highlight_selected_word

Jupyter notebook extension that enables highlighting every instance of the current word in the notebook
Other
61 stars 7 forks source link

Highlighting stuck after scrolling when only_cells_in_scroll is true #28

Open marcevrard opened 6 years ago

marcevrard commented 6 years ago

The highlighting appears to be stuck on the selected word after scrolling down when only_cells_in_scroll is true.

Versions:

Highlight_selected_word 0.1.0
Chrome 64.0.3282.140
Notebook server 5.4.0
Python 3.6.3
IPython 6.2.1
MacOS 10.13.3 or Ubuntu 17.10

The notebook.json:

{
  "Notebook": {
    "Header": false,
    "Toolbar": true
  },
  "load_extensions": {
    "code_prettify/autopep8": true,
    "equation-numbering/main": true,
    "hide_input/main": true,
    "spellchecker/main": true,
    "init_cell/main": true,
    "livemdpreview/livemdpreview": true,
    "python-markdown/main": true,
    "highlight_selected_word/main": true,
    "toc2/main": true,
    "varInspector/main": true,
    "collapsible_headings/main": true,
    "hide_header/main": true,
    "snippets_menu/main": true,
    "zenmode/main": true,
    "hinterland/hinterland": true,
    "help_panel/help_panel": true
  },
  "toc2": {
    "number_sections": false
  },
  "zenmode_use_builtin_backgrounds": false,
  "zenmode_backgrounds": [
    "http://localhost"
  ],
  "highlight_selected_word": {
    "code_cells_only": true,
    "outlines_only": true,
    "words_only": true,
    "highlight_color": "#ff8000",
    "highlight_color_blurred": "#ffb266",
    "use_toggle_hotkey": true,
    "enable_on_load": true,
    "only_cells_in_scroll": true
  },
  "help_panel_add_toolbar_button": true
}
jcb91 commented 6 years ago

My best guess without images is that the 'stuck' highlight is the browser's rendering of actually-selected text in non-focused cells. I'm uncertain off the top of my head how to avoid this with just css, as I can't seem to get anything to override the built-in webkit ::selection style :confused:

jcb91 commented 6 years ago

Scratch that, my mistake. My guess is still that the 'highlights' which remain 'stuck' are actually the selected text in that cell's CodeMirror instance. But, CodeMirror applies the selection styling, so it can be overriden.

marcevrard commented 6 years ago

jnb_short_highlight

marcevrard commented 6 years ago

I've added a screencast and updated the title (and the first comment) since only scrolling seems sufficient to trigger the phenomenon.

jcb91 commented 6 years ago

Hmm, ok, that is something else, then. Will investigate...

jcb91 commented 6 years ago

Seems like overlays were not getting removed correctly. Should be fixed by #31

marcevrard commented 6 years ago

Nice, indeed, it's working on my side with version 0.2.0. Though I have another issue now, not sure it's related. If I highlight a word, it will not be highlighted in the inactive cells not visible at the moment of the selection. This happens whether the following option is selected or not: Only apply highlights to editors which are visible in the scrolled view. This may offer performance benefits for larger notebooks