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

Search for something, hover the popup, but the word/line you searched does NOT highlight. #176

Closed
yarub123 opened this issue Sep 10, 2022 · 8 comments
Labels
enhancement New feature or request

Comments

@yarub123
Copy link

So far this is honestly the best plugin, hands-down. Everything is flawless on my end.
One little thing though, apologies if it's been asked I tried searching:

When you search for a word, for ex, and the results show, and you hold ⌃ or ⌘ so the popup appears, usually (default) it highlights the line in which the search term(s) is located.

This makes it easier to identify whatever you're looking for.

The default "highlight the line/word you're looking for" option seems to be disabled when this plugin is enabled.

Thanks for viewing.

@pjeby pjeby added the enhancement New feature or request label Sep 11, 2022
@pjeby
Copy link
Collaborator

pjeby commented Sep 11, 2022

Unfortunately, the search plugin does not provide this information as part of the hover event, so I'm not sure how we'd implement this -- at the very least it would be rather difficult.

This is because the highlighting is done by the search plugin when you click the result, not when you hover. Even if you use the built-in page preview plugin instead of Hover Editor, you will see that it highlights the entire target line, rather than the specific text match, for the same reason that Hover Editor simply scrolls to that point in the note -- i.e. the search only passes along the line number to the hover preview. There honestly isn't much way for a hover preview to even know it's being invoked by the search in the first place, let alone what the search text was.

In all likelihood, this feature would require changes to Obsidian's search plugin, not just Hover Editor.

@yarub123
Copy link
Author

Sorry I may have obfuscated what I was asking but yes, precisely the line that gets highlighted by the default Obsidian search, that's the feature I was curious about in Hover Editor (HE).

The HE takes me to that line, correct, but was curious if it could highlight the whole line. If I understood you correctly though, it seems rather difficult or not possible to do especially as of yet.

Nonetheless, thank you for the response.

@nhan000
Copy link

nhan000 commented Aug 16, 2023

Hi pjeby, could you have another look at this? I just want it to behave like the built-in Page Preview plugin: highlighting the entire target line.

Even if you use the built-in page preview plugin instead of Hover Editor, you will see that it highlights the entire target line, rather than the specific text match, for the same reason that Hover Editor simply scrolls to that point in the note -- i.e. the search only passes along the line number to the hover preview.

Could you make it so that besides scrolling to that line in the note, Hover Editor also highlights it too?

@pjeby
Copy link
Collaborator

pjeby commented Aug 22, 2023

If you don't care about it also centering that line, it's a pretty easy fix. If you want it to also center it, it's quite a lot of work.

The problem is that the Obsidian search plugin passes different information to the hover event than it does for a click event. The Page Preview plugin knows how to work around this, sort of, but since Hover Editor is trying to pass the info along to a markdown view, the markdown view doesn't behave correctly without the info that the Search plugin only sends when you click.

So, it's easy to work around it to get it to scroll to the line and even highlight the line, but centering requires passing along data that the Search plugin doesn't provide.

@nhan000
Copy link

nhan000 commented Aug 22, 2023

Thanks a lot for looking into this.

I think if the target line is visible in Hover Editor and is highlighted, it is easier to determine where the target line is. My Hover Editor popup is pretty large (900px x 1800px), so centering the target line still leaves me scanning for it. There are also other cases where the target line won't be centered such as if there are other elements such as Twitter or YouTube embed or if the notes is too short.

I think there need to be some clarification here, because the behavior of the Hover Editor is different in the Backlinks + Search vs. in the main panel (note editor) + Outgoing links. I hope this video could clear things up https://drive.google.com/file/d/1-hkaQF6HtS3IT5-ogqzv9o3-XXrwb9nk/view?usp=sharing

To sum up, as long as the target line is visible in the popup, and it's highlighted, I don't think centering is needed, and I prefer highlighting over centering because it's easier to determine the target line.

Let me know if there's anything that isn't clear. Thanks a lot again!

@pjeby
Copy link
Collaborator

pjeby commented Aug 22, 2023

Ok, the updated version (0.11.14) now can do the highlighting, as that was doable with only a little hackiness.

@nhan000
Copy link

nhan000 commented Aug 22, 2023

Just tested it. Works great! Thank you so much!

@yarub123
Copy link
Author

yarub123 commented Sep 4, 2023

Thanks brotha! @pjeby

Also wtf? Time went by that fkn quick?!?! This was opened literally a year ago... Unfknreal.... Life is a trip.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants