You are here: PSPad forum > English discussion forum > reloadUserHighlighter broken?

reloadUserHighlighter broken?

#1 reloadUserHighlighter broken?

Posted by: Professor Bernd | Date: 2020-05-22 15:35 | IP: IP Logged

Since a while the VBScript function "reloadUserHighlighter" does not work anymore. Is it broken or am I using it incorrectly?

My call: reloadUserHighlighter("AutoIt3")

Options: Reply | Quote | Up ^


#2 Re: reloadUserHighlighter broken?

Posted by: Professor Bernd | Date: 2020-05-22 16:07 | IP: IP Logged

I have now found out that the following code loads the user highlighter.

Dim obj
Set obj = NewEditor()
obj.assignActiveEditor()

obj.highlighter("AutoIt3")
reloadUserHighlighter("AutoIt3")

Unfortunately not the current highlighter is used, but a "built-in" one.

To explain the background.

When PSPad starts, my vbscript checks the integrity of the files of my addon. If necessary, the existing file "...\Syntax\AutoIt3.ini" is replaced by a backup. This restored file should now be loaded as a user highlighter, but probably a "built-in" one will be loaded instead.

I suspect PSPad loads the syntax files on startup and the restored syntax file is ignored. Could you change the "reloadUserHighlighter" command to load the restored file?

Edited 1 time(s). Last edit at 2020-05-22 16:08 by Professor Bernd.

Options: Reply | Quote | Up ^


#3 Re: reloadUserHighlighter broken?

Posted by: pspad | Date: 2020-05-22 18:39 | IP: IP Logged

I checked functionality and reloadUserHighlighter function really reloads user highlighter definition.
It looks for a slot where user highlighter is assigned and if it's found, function reloads definition.

I will make some simulation, but call of the function should be enough withtout creating editor and assigning highlighter

I made one change - name of the highlighter won't be case sensitive.

Edited 1 time(s). Last edit at 2020-05-22 18:39 by pspad.

Options: Reply | Quote | Up ^


#4 Re: reloadUserHighlighter broken?

Posted by: pspad | Date: 2020-05-22 18:49 | IP: IP Logged

Just tested.
I used my testing Dummy highlighter.
1. I opened new document with this highlighter
2. Prepare keywords in the document include unknown keywords
3. Prepare script with only call of the reloadUserHighlighter("Dummy")
4. I edit manually dummy.ini and add missing keyword
5. Call of the script
6. In the editor window all keywords include new was highlighted

The condition is the highlighter is assigned in any user highlighter slot. Name of the highlighter as parametr is case sensitive (won't be in the next build)

Options: Reply | Quote | Up ^


#5 Re: reloadUserHighlighter broken?

Posted by: Professor Bernd | Date: 2020-05-22 19:24 | IP: IP Logged

Now that you are writing this, it occurs to me that this was the case when it worked for me some time ago. Now I have found the problem:

Case 1: The error does NOT occur if the AutoIt3.ini exists and is only changed by the backup.

Case 2: The error occurs if there is no AutoIt3.ini and it is created from the backup.

To test it
- Close PSPad.
- Move the AutoIt3.ini from the Syntax folder to another folder.
- Open PSPad with an au3 file with code inside.
- Move the AutoIt3.ini back into the Syntax folder.
- Execute the VBScript command "reloadUserHighlighter".
- The user highlighter will NOT be executed.

If you want to fix this, that's fine, but not necessary. For me it is sufficient that reloadUserHighlighter works for case 1 and to know where the problem is. Case 2 will probably occur rarely.

Thank you very much for testing and for helping me to identify the problem. Thanks for your effort!

Regards,
Bernd.

Edited 2 time(s). Last edit at 2020-05-22 19:26 by Professor Bernd.

Options: Reply | Quote | Up ^


#6 Re: reloadUserHighlighter broken?

Posted by: pspad | Date: 2020-05-22 19:43 | IP: IP Logged

If syntax definition doesn't exists, this is a problem, cause it can't be assigned to the highlighter and even is assigned and later deleted, it isn't loaded during PSpad start. It means AutoIt highlighter doesn't exist and can't be reloaded.

This isn't problem of the script function.

Options: Reply | Quote | Up ^


#7 Re: reloadUserHighlighter broken?

Posted by: Professor Bernd | Date: 2020-05-23 06:56 | IP: IP Logged

I understand that and in my case a deleted syntax file is only a small problem because it rarely appears. Now that I know what the problem is, I can handle it.

Important for my purposes is that "reloadUserHighlighter" works if something in the syntax file has changed. I use this in several script functions, and with your information it works great!

Thank you for your help and information.

Regards,
Bernd.

Options: Reply | Quote | Up ^






Editor PSPad - freeware editor, © 2001 - 2024 Jan Fiala, Hosted by Webhosting TOJEONO.CZ, design by WebDesign PAY & SOFT, code Petr Dvořák, Privacy policy and GDPR