twinejs icon indicating copy to clipboard operation
twinejs copied to clipboard

[2.6] Find fails to find string at various positions in a passage

Open hituro opened this issue 2 years ago • 2 comments

Describe the bug.

When using the Find & Replace dialog, the search often fails to match passages containing the search string. This appears to happen whenever the search string is the first thing on a line, or the first child of an HTML tag with spaces preceding it, but the bug is almost certainly more complex than this (see below).

Steps to reproduce:

search test.html.zip

This zip contains a trivial Twine story in which every passage contains the search token TOKEN. Searching for TOKEN should match every passage, but only matches 5 out of 9

The failed matches appear to occur whenever:

  • TOKEN is the first string on a line
  • TOKEN is the first string on a line following leading whitespace, but only if it is contained in a tag

HOWEVER

Deleting and re-adding passages changes which ones are matched! Copying and pasting text from a matched passage to a non-matched one will not cause it to match, although deleting the passage and re-adding it may (implying a caching issue?). Closing and re-opening the find window can convert some passages from matched to not matched, again seemingly at random.

Expected behavior:

The search works

Additional context on this problem.

I have encountered this issue "in the wild" so to speak, on multiple occasions, but without any clear logic about why a passage is not matched, and sending the file to someone else to open in Twine has the same issues. The file above is just an attempt to produce a working example.

Twine version number

2.5

Does this problem occur with the web version of Twine or the desktop app?

Desktop app

What operating system does this problem occur on?

macOS

If this problem is occurring with the web version of Twine, what browser does it occur on?

None

Presubmission checklist

  • [ ] I am interested in working on code that would fix this bug. (This is not required to submit a bug report.)
  • [X] I have done a search and believe that an issue does not already exist for this bug in the GitHub repository.
  • [X] I have read and agree to abide by this project's Code of Conduct.

hituro avatar Jan 08 '23 18:01 hituro

Does the inconsistency disappear if you copy and paste in your search term all at once? I was doing some work on the fuzzy finder for 2.6 and discovered that there were problems in how I was delaying the search there until after you finished typing, and I think there might be similar problems in the find dialog. Doing a copy/paste means that the text change will happen all at once. Not suggesting this as a real workaround, just trying to see if we are seeing the same problem.

klembot avatar Jan 11 '23 03:01 klembot

Just tried that.

No, pasting the search term back into the Find box (as opposed to typing it) does not find a match in TOKEN + text, TOKEN + text on line 2 or TOKEN in a tag

Oddly, the passage just containing TOKEN as the entire text does get found. But I think that was more of the "inconsistency" aspect as — after closing and opening Twine — that passage is now found under all conditions. Even when I make it's text identical to a "not found" passage it is still found, suggesting some sort of caching.

hituro avatar Jan 11 '23 09:01 hituro