Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ctrl+F glitchy when switching between files #2125

Open
greenStone83 opened this issue Feb 23, 2023 · 1 comment
Open

Ctrl+F glitchy when switching between files #2125

greenStone83 opened this issue Feb 23, 2023 · 1 comment
Labels
Area:Editor For CodeMirror-related features Bug

Comments

@greenStone83
Copy link

greenStone83 commented Feb 23, 2023

  • p5.js version: 1.5.0

  • Web browser and version: Chrome, Firefox, and Edge, most recent

  • Operating System: Windows 11

  1. Go to this link and go to sketch.js
  2. Ctrl+F and type "test". Notice there are 4 instances of "test"
  3. Switch to new.js and press the "next" (down arrow) on the Ctrl+F bar
  4. Notice it always says 0/4 (it should say 1/2 and 2/2 I assume)
  5. Type another "test" in new.js and hit the down arrow
  6. Notice it says there are now 7 instances of "test" (it should say 3 I assume)

https://editor.p5js.org/greenStone83/sketches/IQMmFIkYv

@lindapaiste
Copy link
Collaborator

lindapaiste commented Feb 25, 2023

This a great bug report!

I found where in the code the "0/4" gets set:

var next = cm.state.search.annotate.matches
.findIndex(s => s.from.ch === cursor.from().ch && s.from.line === cursor.from().line) + 1;
var text_match = next + '/' + num_match;
cm.display.wrapper.querySelector('.CodeMirror-search-results').innerText = text_match;

I'm kind of surprised that none of it is React. The text of the DOM element is manually changed when the findNext function is called. I would have to dig into this more to fix it, as I'm not familiar with CodeMirror. I suspect that some of these issues of outdated state could be resolved by generating the search bar markup in React, even if we still have to use react-dom/renderToString() to pass it the CodeMirror openDialog. But I'm not sure that it's even necessary to handle the dialog through CodeMirror, vs. passing the CodeMirror instance as a prop to a React component.

Possibly related to #2081

@lindapaiste lindapaiste added the Area:Editor For CodeMirror-related features label Jan 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area:Editor For CodeMirror-related features Bug
Projects
None yet
Development

No branches or pull requests

2 participants