Bookmark multi words from multi lines in a text
-
So somewhere between writing the first version of the script, and the changing of it to create the second script, I decided that it made sense to require that the “data” file you want the markings to be shown in should be the active file in the primary view, and the “list” file of tokens/regexes that should be used to do the markings should be the active file in the secondary view, when the script is run. It is an unwritten requirement (except that I just wrote it!).
The first version of the script, because it was simpler and only one “word” was expected per line in the “list” file, tried to determine which view contained which.
Aside from that, with the second version of the script, I’m not seeing the problems you mention. Can you give an exact example that replicates the behavior?
-
Hi, @alan-kilborn,
For instance, with :
-
Your text pasted, in
new 1
, in the main view -
A list of four first names, pasted in
new 2
, in the secondary view -
Cursor at the very beginning of
new 1
-
Focus on
new 1
( the text )
After running the script, I got :
As you can see, all bookmarks are here, but some red marks are missing ! The script seems to only
red-mark
the first occurrence of each word of the list !
In contrast to :
-
Your text, pasted in
new 1
, in the main view -
A list of four first names, pasted in
new 2
, in the secondary view -
Cursor at the very beginning of
new 2
-
Focus on
new 2
( the list )
After running the script, I got :
This time, everything went fine !
Cheers,
guy038
-
-
I think I remember something about possibly Notepad++ code itself interfering with scripts that are trying to use indicators?
Perhaps the code in the script that “selects” an indicator needs to be “tighter” to where the indicator is used?
Maybe try changing these lines of the script:
editor1.setIndicatorCurrent(SCE_UNIVERSAL_FOUND_STYLE) for m in matches: editor1.indicatorFillRange(m[0], m[1] - m[0])
to this instead, and see if it runs differently?:
for m in matches: editor1.setIndicatorCurrent(SCE_UNIVERSAL_FOUND_STYLE) editor1.indicatorFillRange(m[0], m[1] - m[0])
(really what this means is just moving the “setting” of the indicator inside the loop, so that it is definitely set each time before a range is “filled” with it)
Let me know how that goes.
-
BINGO ! It works like a charm, whatever the focus is ( The main or the secondary view ) ;-))
You’re right : placing the indicator’s definition inside the loop is the key point !
Many thanks, again, for your cooperation :)
Just to be sure : did you reproduce the issue, too, when focus is in the analyzed text view ?
BR
guy038
-
@guy038 said in Bookmark multi words from multi lines in a text:
did you reproduce the issue, too, when focus is in the analyzed text view ?
Mostly it worked okay for me on simpler data sets.
But I noticed it as an issue when I was looking into a larger-dataset problem, e.g. THIS ONE, and that made me recall an issue where an indicator needs to be set right before a fill, even though the indicator was set earlier and still should remain set. -
Hello,@BAZ-BAZOOO
Please follow this information, To Bookmark multi words from multi lines in a textFind What:
(.Query . message.\R.ApplicationGatewayID = 5009.\R.\R.\R)|^(?!.Query . message).\R?
Replace With:
$1The regex is of the form:** (<YOUR_REGEX_MATCHING_LINES>)|^(?!.<STARTING_PART_OF_REGEX>).\R?.**
Description:
-
(.Query . message.\R.ApplicationGatewayID = 5009.\R.\R.*\R) - a line with Query and then message words on it, then the next line that has ApplicationGatewayID = 5009 on it and then 2 more lines, captured into Group 1 ($1 refers to this value)
-
| - or
-
^(?!.Query . message).*\R? - start of a line (^) that has no Query and then message on it, then the whole line and optional linebreak after it are matched and eventually removed.
I hope this information will be useful to you.
Thank you. -
-
The marker ID used for bookmarks changed in Notepad++ 8.4.6 (and later). It is now 20, instead of 24. So, all references to 24 in this thread and/or its script(s), should be changed to 20.