mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2024-11-19 08:14:50 +00:00
changed 2 loops resolving name conflicts for new tiddlers as suggested in issue 294
This commit is contained in:
parent
638c8b2070
commit
42ba6852d1
@ -322,11 +322,10 @@ NavigatorWidget.prototype.handleNewTiddlerEvent = function(event) {
|
|||||||
// Create the new tiddler
|
// Create the new tiddler
|
||||||
var baseTitle = (templateTiddler && templateTiddler.fields.title) || "New Tiddler",
|
var baseTitle = (templateTiddler && templateTiddler.fields.title) || "New Tiddler",
|
||||||
title;
|
title;
|
||||||
for(var t=0; true; t++) {
|
var t = 0,
|
||||||
title = baseTitle + (t ? " " + t : "");
|
title = baseTitle;
|
||||||
if(!this.wiki.tiddlerExists(title)) {
|
while (this.wiki.tiddlerExists(title)) {
|
||||||
break;
|
title = baseTitle + " " + (++t);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
var tiddler = new $tw.Tiddler(this.wiki.getCreationFields(),{
|
var tiddler = new $tw.Tiddler(this.wiki.getCreationFields(),{
|
||||||
text: "Newly created tiddler",
|
text: "Newly created tiddler",
|
||||||
|
@ -173,11 +173,11 @@ exports.tiddlerExists = function(title) {
|
|||||||
Generate an unused title from the specified base
|
Generate an unused title from the specified base
|
||||||
*/
|
*/
|
||||||
exports.generateNewTitle = function(baseTitle) {
|
exports.generateNewTitle = function(baseTitle) {
|
||||||
var c = 0;
|
var c = 0
|
||||||
do {
|
title = baseTitle;
|
||||||
var title = baseTitle + (c ? " " + (c + 1) : "");
|
while(this.tiddlerExists(title) {
|
||||||
c++;
|
var title = baseTitle + " " + (++c);
|
||||||
} while(this.tiddlerExists(title));
|
};
|
||||||
return title;
|
return title;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user