Templater icon indicating copy to clipboard operation
Templater copied to clipboard

tp.file.cursor(1) not working

Open Lorena1908 opened this issue 2 years ago • 37 comments

Plugin informations (please complete the following information):

  • OS: Windows 10
  • Templater version: 1.9.9
  • Obsidian version: v0.12.15

Describe the bug When I insert a template that has <%tp.file.cursor(1)%>, this is not replaced by the cursor

Expected behavior This code should be replaced by the cursor

Screenshots Here is a screen recording

https://user-images.githubusercontent.com/80294221/135774090-4dcde689-d07f-4d4c-8a06-cb3d84e2978a.mp4


Extra information:

I noticed this happened because of the latest version: 1.9.9, because when I downgraded to the previous version (1.9.8) it worked properly.

Lorena1908 avatar Oct 03 '21 22:10 Lorena1908

Hey @Lorena1908, the automatic cursor jump is now disabled by default. You can enable it back in the settings of Templater.

SilentVoid13 avatar Oct 04 '21 08:10 SilentVoid13

Thank you for the great extension @SilentVoid13 !

That the automatic cursor jump needs to be enabled separately might be something worth mentioning in the docs. Being new to the extension, it puzzled me greatly that omitting the () printed out the function body, while having the () just did nothing. Even if the automatic cursor jump is disabled, I would expect to see the code block disappear, but I guess there exists some good reasons why this isn't so :)

poacher2k avatar Oct 04 '21 13:10 poacher2k

well, it's ok for it to be configurable, but I think it's really not a good idea to add a setting with the default opposite of the current behaviour. and a dozen bug reports for the same issue is an obvious result.

vitaly avatar Oct 12 '21 07:10 vitaly

It was confusing to me that it looks like it doesn't parse the entire code block. (eg: it prints the text of <% tp.file.cursor(1) %> in the output)

suggest instead to:

  1. replace with blank string in the output
  2. log a console warning/info if the setting is off
  3. turn the setting on by default (unless there's some downside to this?)

SimplGy avatar Jan 04 '22 05:01 SimplGy

Whether it was broken before or not, it's definitely broken now for me using latest stable versions of plugin (1.12.0) and Obsidian (0.15.9) on Mac. Double-checked that I still have the setting set to on, but it's just showing the string and not replacing it. Please fix!

bjornfiles avatar Aug 30 '22 20:08 bjornfiles

It defaults to file name now

odyslam avatar Sep 04 '22 09:09 odyslam

Can confirm defaulting to file name for me after update to 1.14.1 for me this morning. Hope there is a fix for it

jonnymauser76 avatar Sep 15 '22 13:09 jonnymauser76

Obsidian's default behaviour has changed which is why this command no longer works as expected.

shabegom avatar Sep 17 '22 14:09 shabegom

This is not working in v0.15.9, the hotkey "Templater: Jump to next cursor location" IS WORKING but not the automatic jump. Hoping there is a fix for this.

zubayrrr avatar Oct 07 '22 03:10 zubayrrr

It costs me half an hour to figgle around and find this.

For me <% tp.file.cursor(1) %> does not work at all, but I'm new with templater. I need a precise guide (preferable in the docs).

merlinuwe avatar Oct 11 '22 15:10 merlinuwe

Sorry to hear. It's still broken last I checked and it'll be a while before it gets fixed. If anyone wants to take a stab at it, I'm happy to guide them!

AB1908 avatar Oct 11 '22 15:10 AB1908

Also happy to merge a warning in the docs that this isn't working as expected right now.

shabegom avatar Oct 12 '22 03:10 shabegom

It costs me half an hour to figgle around and find this.

For me <% tp.file.cursor(1) %> does not work at all, but I'm new with templater. I need a precise guide (preferable in the docs).

came here to say this. exact same situation

fringemonkey avatar Oct 21 '22 19:10 fringemonkey

just to add that it does work when the note is created with templaters own cmd + p methods - but I was using the quickAdd plugin to create my templates and it doesn't work with that out of the box so if your using the quickadd plugin (or I assume another) enabling trigger template on new file creation will fix it.

image

my template

---
title: '<%tp.file.title%>'
tags: 
visibility: private
created: <%tp.date.now("Y-MM-DDTHH:mm:ssZZ")%>
---

# <%tp.file.title%>


<%tp.file.cursor(0)%>


## Links

- 

## Reference

- 

apricot13 avatar Nov 01 '22 16:11 apricot13