Templater
Templater copied to clipboard
tp.file.cursor() puts the cursor at the beginning of the line if there are greater than 65,536 (2^16) characters
Plugin information (please complete the following information):
- OS: Windows 10
- Templater version: 1.12.0
- Obsidian version: 0.14.15
- Templater settings: default settings
Describe the bug
When there are more than 65,536 (2^16) characters in a file after tp.file.cursor()
finishes it's replacement, the cursor is put to the start of the line rather than to the correct position.
If there are less than 2^16 characters after replacement, everything works fine.
Expected behavior The cursor should jump to the correct position on the line.
Screenshots
Pay attention to the character count in the bottom right
https://user-images.githubusercontent.com/6267244/176325914-460b67a8-7b70-4fdc-a284-235fe7e6c6e2.mp4
Additional context
It is possible that this is an issue with the EditorPosition
interface, which I believe implements position (or ch) as a TypeScript number
https://marcus.se.net/obsidian-plugin-docs/api/interfaces/EditorPosition https://github.com/marcusolsson/obsidian-plugin-docs/blob/main/obsidian.d.ts (line 871)
Edit: Here is the test file with the thousands of characters for your own testing
templater-cursor-example.md
I'm seeing this as well. I have a daily log file that I just append to the beginning of and now when I apply the template for the daily log my cursor is positioned before rather than after the list marker.
## <% tp.date.now("YYYY/MM/DD dddd") %>
-<% tp.file.cursor(1) %>
i am also having this issue. Wonder if anyone has a fix for this?
Update for anyone else experiencing this issue. I have made a quick plugin fix that can be used in conjunction with Templater as a replacement for the template-cursor functionality. Download found on my github profile here.