Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

When using tp.file.cursor inside an internal link, cursor is placed before the link #1419

Open
Tejeev opened this issue Jul 24, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@Tejeev
Copy link

Tejeev commented Jul 24, 2024

Plugin information (please complete the following information):

  • OS: xubuntu 22.04.4 LTS
  • Templater version: 2.3.3
  • Obsidian version: v1.6.7
  • Templater settings: [e.g. Template folder location: "Templates/", Timeout: "5" (add the templates not working with their associated command)]

Describe the bug
In a file created with the following template, using the hot key for Templater: Jump to next cursor location while in preview mode places the cursor before the brackets instead of within them

[[<% tp.file.cursor(1) %>#heading1]] 

Doing the same while the editor is in source mode performs as expected
Expected behavior
Hitting the cursor placement hot key should put the cursor directly after [[

Screenshots
Highlighted to show syntax:
image

As it appears in editor preview mode:
image

After hitting hot key in preview mode (bad behavior):
image

After hitting hot key in source mode (expected behavior):
image

Other Notes:
I have found that I often can not use the mouse to place the cursor inside the link to edit the text (change the cursor from 2 to 3, for example). When I click on the text the cursor is placed outside the final square bracket and I have to use arrow keys to navigate into it. While this feels related, I'm not sure because I find the behavior is the same in both source and regular preview editor modes.
image

@Tejeev Tejeev added the bug Something isn't working label Jul 24, 2024
@23maverick23
Copy link

OS: OSX 14.5
Templater version: 2.4.1
Obsidian version: 1.7.0
Templater settings: Automatic jump to cursor [True]

Just adding that this doesn't appear to be limited to "headings" and instead seems to be happening with any wikilink and tp.file.cursor() combination. May want to update the issue title to reflect this.

My "Insert wikilink from selection" template snippet no longer works as expected. The cursor is either placed outside the start of the wikilink brackets ([[), or it is placed inside the brackets but does not trigger the native Obsidian auto-complete dropdown menu. Pressing the spacebar will bring up the native Obsidian auto-complete dropdown menu, which leads me to believe tp.file.cursor() isn't firing the required event(s).

Template snippet being used (this is currently called via Commander, however calling from the Command Palette has the same effect).

[[<% tp.file.cursor() %>|<% tp.file.selection() %>]]

@Tejeev Tejeev changed the title When using tp.file.cursor inside an internal link with a heading, cursor is placed before the link When using tp.file.cursor inside an internal link, cursor is placed before the link Aug 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants