<p>I have also just found another case where the highlighting goes wrong (C++).</p>

<p>Near top of file I had <code>struct Foo{};</code> a definition, so <code>Foo</code> was highlighted everywhere.</p>

<p>Changed it to a forward <code>struct Foo;</code> so <code>Foo</code> was unhighlighted since forwards don't cause highlighting (why is another question).</p>

<p>Scrolled down a bit and added <code>struct Foo { some stuff };</code> and all visible instances of <code>Foo</code> were highlighted, but scroll back and previous instances of <code>Foo</code> were not highlighted.</p>

<p>The same happens when previous instances were highlighted and a change is made that should unhighlight all instances, those before the first visible line remain highlighted.</p>

<p>Essentially any change to the file that causes a change in highlighting seems to not be applied before the current first visible line.</p>

<p>IIUC Scintilla considers the styling to be invalid from some point forward, so if we tell Scintilla that the first visible line forward is invalid, it has no reason to re-lex when scrolling back, since it was before the invalid point.  </p>

<p>So if we make any change that may change the lexing in the file we need to re-lex the whole file, not just the visible bit forward.  Such a change is uploading new wordlists and that should trigger a whole file re-lex.</p>

<p>Unfortunately I don't think we currently have a way of checking if the wordlists have changed, so that re-lex has to occur each parse.</p>

<p style="font-size:small;-webkit-text-size-adjust:none;color:#666;">—<br />You are receiving this because you are subscribed to this thread.<br />Reply to this email directly or <a href="https://github.com/geany/geany/pull/1022#issuecomment-218684519">view it on GitHub</a><img alt="" height="1" src="https://github.com/notifications/beacon/ABDrJ27jWP5FxBWW10RU-HpCCwc4e1RBks5qAttsgaJpZM4IXArK.gif" width="1" /></p>
<div itemscope itemtype="http://schema.org/EmailMessage">
<div itemprop="action" itemscope itemtype="http://schema.org/ViewAction">
  <link itemprop="url" href="https://github.com/geany/geany/pull/1022#issuecomment-218684519"></link>
  <meta itemprop="name" content="View Pull Request"></meta>
</div>
<meta itemprop="description" content="View this Pull Request on GitHub"></meta>
</div>