twinejs
twinejs copied to clipboard
Editing text within a double square bracket link creates multiple empty passages
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.
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
- The passage has no text AND
- The passage is only linked from the passage that was edited
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.
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:
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.
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:
- Author has finished typing the Target Passage Name.
- 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:
- all those references need to be changed.
- 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 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.
See https://github.com/klembot/twinejs/pull/1222
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.
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).
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.
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.
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.
I had this issue very often in 2.4. But now in 2.5 the functionality seems perfect.
👍 I'll close this but if people encounter this problem again, please re-open with details.