tp.file.cursor() puts the cursor at the beginning of the line if there are greater than 65,536 (2^16) characters
Opened this issue · 3 comments
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
Obsidian_2022-06-28_18-24-17.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?