TiddlyWikiClassic
TiddlyWikiClassic copied to clipboard
Bug: renaming a tiddler to an existing one
Issue
Renaming a tiddler whilte overwriting an existing tiddler doesn't delete the one being renamed.
Test
- Create tiddler [[Foo]].
- Then create tiddler [[Bar]].
- Then rename tiddler [[Bar]] to [[Foo]].
Here's an MTC: http://up.tiddlyspace.com — I have added Eric as a member to the space.
~
Also, deleting a tiddler doesn't seem to refresh the display. Meaning: tiddlyLinks appear as existing even though the tiddler has been deleted.
This issue is due to the behaviour of the Story.prototype.saveTiddler
[1]. More precisely, in this case the line 604 is processed, which prevents the store.saveTiddler
call [3] from seeing that the title
was different from the newTitle
.
Moreover, after the line [2] the changed var title
is used 4 times and, as far as I can see, in each one it should be old title rather than new one.
So, my solution on fixing this is to remove the line [2]: instead of
if(store.tiddlerExists(newTitle) && newTitle != title) {
if(!confirm(config.messages.overwriteWarning.format([newTitle.toString()])))
return null;
title = newTitle;
}
(note also the wrong indentation), there should simply be
if(store.tiddlerExists(newTitle) && newTitle != title)
if(!confirm(config.messages.overwriteWarning.format([newTitle.toString()])))
return null;
(I've already tested this a bit using a plugin that overwrites the Story.prototype.saveTiddler
function)
Best regards,
Yakov.
[1] https://github.com/TiddlyWiki/tiddlywiki/blob/master/js/Story.js#L590 [2] https://github.com/TiddlyWiki/tiddlywiki/blob/master/js/Story.js#L604 [3] https://github.com/TiddlyWiki/tiddlywiki/blob/master/js/Story.js#L629
Fixed in c6a488c, will make it into the version after 2.9.3 (probably 2.9.4), so closing this now