On 23/02/03 4:26 AM, Bram Moolenaar wrote:
Ernie Rael wrote:

I want to determine what text property, if any, is under the mouse
position. The best options seems to be

     prop_find({lnum: mpos.line, col: mpos.column, ...})

and then check if the returned property covers the mouse position.

I am wondering about having an "exact: true" option in prop_find's
"search for" options. When "exact: true" a property is only returned
if (lnum, col) are covered by the property, otherwise an empty
dictionary is returned.

Using this would minimize extra code, including vim9 code to check
if returned property covers mouse pos. This is used on every mouse
movement event, would be nice to minimize overhead.

Would a patch that adds "exact: true" be considered? I haven't looked
at the code yet; first looking for comments on this approach.
prop_find() can be inefficient, since it searches the whole buffer.
That is especially when no match is found.

Right. The idea is that when "exact: true", prop_find only checks if there is a prop match at lnum/col. If there is a match, return the prop otherwise immediately return empty; there is no search when "exact" is true. I suppose "exact_location" is more
descriptive, but longer.


How about using prop_list() instead?  It only checks for properties in
one line, which is what you want.  We could add a "col" entry in the
{props} argument to narrow down to properties that include this column.

The current prop_list is not too bad since the search already can be limited. Still requires searching the returned list. Was trying to avoid checking if the returned props overlap mouse pos, but I tend to over optimize while looking to minimize vim9script code in favor
of  builtins.

I almost didn't mention it at all since it does seem pretty minor, I even thought about prop_find_at(...) which implies exact and lnum/col could be required positional args.
Like I said, tend to over optimize.

-ernie


--
--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- You received this message because you are subscribed to the Google Groups "vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_dev/d756524c-817b-8346-1fc6-b7ebf847819a%40raelity.com.

Raspunde prin e-mail lui