Author Topic: Coloring and reloading modified files.  (Read 665 times)

jporkkahtc

  • Senior Community Member
  • Posts: 2509
  • Hero Points: 206
  • Text
Coloring and reloading modified files.
« on: January 18, 2022, 10:33:12 pm »
I've been working with files that are created during a build - having some of these generated source files open in Slickedit.
I've been seeing Slickedit get the coloring confused after files are reloaded, and I haven't seen a good way to fix it when it happens.

See the attached screen shots. I replaced "[a-z]" with "Q" to obfuscate for posting here.
The Replace operation didn't change the coloring.
Note in the 2nd image, I removed the "//" prefix so the line is no longer a comment, and still the coloring for some of the letters is wrong.

I also tried using "Tools > Options > Appearance > Colors", and clicking on various things.
Clicking anywhere in the "Q"s tells me "Line Comment"
Once I remove the "//" from line 38, clicking on any "Q" tells me "Identifier" - even the ones that are the wrong color.

If I change the ColorProfile (for example, to Black") these mis-colored letters are still colored incorrectly (changing to yellow).

When I change the color for "Keyword", those "Q"s update to match.

Clark

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 6271
  • Hero Points: 484
Re: Coloring and reloading modified files.
« Reply #1 on: January 19, 2022, 09:01:10 am »
Anyway you can give us a reproducible test case?

jporkkahtc

  • Senior Community Member
  • Posts: 2509
  • Hero Points: 206
  • Text
Re: Coloring and reloading modified files.
« Reply #2 on: March 02, 2022, 06:24:42 pm »
I keep seeing this problem.
See the attached colors in the comment in a C# file.

This is generated code.
However, the coloring is preserved when I close the file and open it again. (Case1)

If I open Tools > Options > Appearance > Colors, then click on the letters with the wrong colors, Options still indicates "Line Comment" -- just as it does for all of the correctly colored comment characters.

If I delete the "//" the badly colored characters stay badly colored (Case2), while rest of the comment is recolored as "Identifier" (the ":" is colored as "Operator").

Inserted characters inherit the bad colors around them (Case3)

Case4 and Case5: More of the same, this time starting out not commented.
Is there something I can do to track this down?
Its not really serious, but it is distracting.

Clark

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 6271
  • Hero Points: 484
Re: Coloring and reloading modified files.
« Reply #3 on: March 02, 2022, 10:43:38 pm »
Since you can remove the // and the text still doesnt look right I’m guessing this is not color coding. It’s probably some stream markers. try deleting ALL the incorrectly colored characters that are not in comment color. Then type the same characters back in. If the wrong color doesn’t come back, the color is from some stream markers. I have no idea what’s creating the stream markers.

jporkkahtc

  • Senior Community Member
  • Posts: 2509
  • Hero Points: 206
  • Text
Re: Coloring and reloading modified files.
« Reply #4 on: March 03, 2022, 07:28:09 pm »
Deleting the miscolored text, then undoing fixes the coloring.

I made a function to dump the stream markers. In the file in question there are lots of them. The following one is one inside a comment where some text is miscolored.
    Marker:13742, Start=27452, Color:17, Type:172, Flags0, Flags2=16, Pri=225

What I think are the relevant definitions
const VSMARKERTYPEFLAG_AUTO_REMOVE=        0x10;
VSMARKER_TYPE_PRIORITY_KEYWORDS           = 225,

My code
Code: [Select]
_command listmarkers() name_info(','VSARG2_MACRO|VSARG2_MARK|VSARG2_REQUIRES_EDITORCTL)
{
    int list[];
    int wid = p_window_id;
    wid._StreamMarkerFindList(list, wid, 0, wid.p_buf_size, VSNULLSEEK, 0);
    foreach (auto sm in list) {
       VSSTREAMMARKERINFO info;
       if (_StreamMarkerGet(sm, info) == 0) {
           if (info.StartOffset > 27400) {
               int flags = _MarkerTypeGetFlags(info.type);
               int pri = _MarkerTypeGetPriority(info.type);
               say("Marker:"sm", Start="(info.StartOffset)", Color:"(info.ColorIndex)", Type:"(info.type)", Flags"(info.MarkerTypeFlags)", Flags2="flags", Pri="pri);
           }
       }
    }
}

Dennis

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 3602
  • Hero Points: 480
Re: Coloring and reloading modified files.
« Reply #5 on: March 03, 2022, 08:29:44 pm »
Do you have positional keyword coloring enabled for C# ?  (Document > C# Options > View)

jporkkahtc

  • Senior Community Member
  • Posts: 2509
  • Hero Points: 206
  • Text
Re: Coloring and reloading modified files.
« Reply #6 on: March 04, 2022, 01:15:47 am »
Yes

Dennis

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 3602
  • Hero Points: 480
Re: Coloring and reloading modified files.
« Reply #7 on: March 04, 2022, 01:05:41 pm »
OK, try turning it off.  If the coloring problem on reload goes away, then we know where the problem is.  Note that if you already have a file in a state where the coloring is not right, just turning off positional keyword coloring is not likely to fix anything, you will probably need to close and restart the editor and try to reproduce the problem.

Dennis

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 3602
  • Hero Points: 480
Re: Coloring and reloading modified files.
« Reply #8 on: March 09, 2022, 05:01:30 pm »
Did turning off the positional keyword coloring setting help?

jporkkahtc

  • Senior Community Member
  • Posts: 2509
  • Hero Points: 206
  • Text
Re: Coloring and reloading modified files.
« Reply #9 on: March 09, 2022, 05:18:01 pm »
I haven't had a chance to test it yet.
I mostly notice this when I'm debugging my code generation stuff ... I've still got more bugs here to look at, so soon :-)

jporkkahtc

  • Senior Community Member
  • Posts: 2509
  • Hero Points: 206
  • Text
Re: Coloring and reloading modified files.
« Reply #10 on: March 10, 2022, 12:59:16 am »
Verified -- turning off  positional keyword coloring fixes the problem.

Dennis

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 3602
  • Hero Points: 480
Re: Coloring and reloading modified files.
« Reply #11 on: March 10, 2022, 02:17:13 pm »
Reproduced.  Hopefully this will be hot-fixable, otherwise, the fix will be in 26.0.2.