twinejs icon indicating copy to clipboard operation
twinejs copied to clipboard

Editing text within a double square bracket link creates multiple empty passages

Open upstartfrog opened this issue 2 years ago • 12 comments

Describe the bug.

Creating a link with a [[ ]] bracket markup will dynamically auto-generate a linked passage with the title of the link. Editing this link text will, every few seconds, automatically generate another new passage titled with the current name of the link, leaving the original passage present. This results in multiple unwanted new passages.

Steps to reproduce:

  • Open a new passage.
  • Type a link with double square bracket markup. E.g. [[TEST]]. This creates a linked passage called TEST.
  • Without closing the passage editor, edit the link within the square bracket to [[TEST 2]]. After a second or so, the passage view refreshes with the new passage TEST 2. The TEST passage remains as an orphaned link.
  • Further edits create further new passages and more orphaned passages.

Expected behavior:

Either auto-generated passages should be created only on closing the passage editor.

Or, possibly, the auto-generated linked passages should rename dynamically when the link text is edited.

Additional context on this problem.

I have replicated this issue on the Windows and browser version.

Twine version number

2.4.0

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

Desktop app

What operating system does this problem occur on?

Windows

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

No response

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.

upstartfrog avatar Jul 06 '22 20:07 upstartfrog

I really like

Or, possibly, the auto-generated linked passages should rename dynamically when the link text is edited.

But that logic seems tricky to parse out. Something perhaps like

  1. The passage has no text AND
  2. The passage is only linked from the passage that was edited

klembot avatar Jul 07 '22 00:07 klembot

Wouldn't it be easier to keep an ephemeral list of passages created in this editor instance since the passage was last opened, and then change only those ones? You'd have to track which link created which passage as well, which might be extra tricky, or track the pre-edit and post-edit text of the given link.

I've seen exactly the same behaviour where I've misspelled a link name and gone back to edit it, resulting in 3 or 4 passages being left on the story map. If it's not possible to track the created passages and rename them, then the time between stopping typing and creating the passage should probably increase.

hituro avatar Jul 07 '22 07:07 hituro

I saw this in 2.4.1 on MacOS (Big Sur) while looking at a different bug. I don't recall it happening pre-2.4, so maybe some anti-bouncing was lost in translation and can be restored without implementing new logic?

A screenshot, because I took it: Screen Shot 2022-07-25 at 3 35 52 PM

mcdemarco avatar Jul 25 '22 19:07 mcdemarco

The timing was changed between 2.4.0 and 2.4.1, and it's not as bad as it was, but it definitely still happens. I've started being very cautious about writing links which I might need to edit.

hituro avatar Jul 25 '22 19:07 hituro

The problem with automatically doing things without confirmation after a brief pause in typing is how are the "Create Missing Passage" feature, and the related "Rename Referenced Passage" feature, meant to distinguish the difference between when:

  1. Author has finished typing the Target Passage Name.
  2. Author has paused to think while typing the Target Passage Name.

And regarding automatically renaming an existing Passage when the the Target Passage Name of a markup link has been changed, you need to first determine if there are any other references (markup link or macro based) to that Passage in any Passage (current or other), and then determine if:

  1. all those references need to be changed.
  2. a new Passage needs to be created.

I believe the complexity of the above was one reason why the Twine 1.x application waited until the Passage Editor was being closed before asking the Author if they wanted missing Passages to be created.

greyelf avatar Jul 25 '22 21:07 greyelf

Greyelf makes good points. I think I'd be content to revert to the 2.3 behaviour. The utility of having the new passages appear as you type doesn't outweigh the pain of editing links or deleting handfuls of accidental passages.

hituro avatar Jul 25 '22 21:07 hituro

See https://github.com/klembot/twinejs/pull/1222

klembot avatar Jul 25 '22 21:07 klembot

Very curious what folks here think of the change in the linked PR. I have experimented with it somewhat myself and haven't been able to trick it into doing something destructive, but I don't think I'm a representative user.

klembot avatar Jul 25 '22 21:07 klembot

I love the visual indication of empty passages, that's a lot better than my suggestions for a search/highlight, but I am a little worried about the potential for the search of "is this passage linked from another passage" to be slow when the number of passages becomes very large (we know people have 1000+ passage stories).

I was wondering if you didn't already know how many incoming links a passage has because you have to draw them live on the story map. If you cache that information you wouldn't have to search all open passages for links to the orphan. (I'm guessing that the map updates already require you to search all passages).

hituro avatar Jul 25 '22 22:07 hituro

Yeah, performance was a concern for me too. FWIW, I tested with Birdland which has 927 passages, and did not notice any performance issues. But this is just one data point.

klembot avatar Jul 25 '22 22:07 klembot

Well, if you do all-passage searches already to draw the story map and provide the passage name suggestion list, then you are probably fine.

hituro avatar Jul 25 '22 22:07 hituro

I should mention that I type all the brackets before filling in any of the link or link text, so I am always "editing" an existing link. This probably made my passages proliferate faster than @hituro's, even in 2.4.1.

I wonder if issue #1202 is related somehow.

mcdemarco avatar Jul 26 '22 01:07 mcdemarco

I had this issue very often in 2.4. But now in 2.5 the functionality seems perfect.

hhrichards avatar Sep 01 '22 09:09 hhrichards

👍 I'll close this but if people encounter this problem again, please re-open with details.

klembot avatar Sep 03 '22 14:09 klembot