Possible Bug in action-createtiddler Widget

The action-createtiddler widget does not remove trailing spaces in the title.

\procedure create-action() <$action-createtiddler  $basetitle="with trailing space  "/>

<$button actions=<<create-action>> >
Create Tiddler
</$button>
  • Click on create tiddler button
  • Edit the created tiddler entitled with trailing space and note to the trailing spaces in title
  • It seems action-createtiddler does not remove trailing space

I would imagine in most cases, any space at the end of the $basetitle variable would be unintended, specially if the $basetile is being set to another variable, but if someone intended to add additional spaces, they would not be able to if the $basetile was automatically trimmed of trialing white space. I mean if I wanted my base title to have two spaces after it before the automatically included numerical counter if the title already exists, for whatever reason, I would expect it to retain what ever text I put into the $basetitle variable. It would probably be better that you ensure any variables you assign to $basetile are already trimmed before doing the action-createtiddler rather than force it to remove trailing spaces which may be wanted if someone does it specifically.

1 Like

I agree with @CasperBooWisdom as I have done this in the past, the base title says this is the title from where the ultimate title is generated so it is quite reasonable to include trailing spaces. However if a tiddler was created with a trailing space I think you will find it will get removed on the first edit of the tiddler.

  • If you are concerned you can use trim
[[ This is the title with or without whitespace suffix and or prefix ]trim[]]
[{!!title}trim[]]

in triple curly braces (the filtered transclusion), or the backtick filter form to garentee no leading or training whitespace.

The issue is you cannot use createTiddler-title properly, for example below code creates two tiddlers one with trailing space one with trimmed space, and this is a bug! (Note new-item-title is a calculated base title with trailing space

  <$action-createtiddler $basetitle=<<new-item-title>> $template=<<thisTemplate>> >
    <$action-listops $tiddler=<<createTiddler-title>> $tags="[<currentTiddler>] [[Easy]] -[[$:/tags/Template]]"/>
    <$action-sendmessage $message="tm-edit-tiddler" $param=<<createTiddler-title>>/><!-- open newly created tiddler in edit mode -->		
  </$action-createtiddler>

IMO you should create an issue at GitHub, otherwise it will be forgotten.

Is there a way for a workaround using the trim[] filter?

1 Like

Ahh, so you are saying that the createTiddler-title variable is always created trimmed, even if the trailing spaces are included in the $basetitle variable. Yeah, I would say that is a bug. I was also unaware that you could not have trailing spaces in a tiddler title, not that I ever wanted to, but I just didn’t know that upon the first edit of the tiddler it would be auto trimmed anyway. That being the case, then yes, the $bastitle variable should always be trimmed by default in the widget code and that would take care of the createTIddler-title problem.

I just tested it myself as well, and it definitely creates 2 separate tiddlers, and if I have them both opened in the river, and I edit the one with spaces and then save it again, when it tries to remove the spaces, as stated earlier where they are auto trimmed on the first edit, it finds that one without spaces already exists, so instead of renaming it without spaces, it saves it again with spaces, but the river, for a split second, thinks they are the same tiddler, so it quickly removes the tiddler with spaces from the river, even though it still exists, you just have to go find it again.

I actually used another procedure to create a base title like Q001: , Q002: … when I tried to use createTiddler-title subsequently I saw two tiddlers were created. What I call it a bug! So, I decided to use Q001: New Question, and Q002: New Question