Code intelligence doesn't wrap non-highlighted code units
Currently, we expect that every code unit is wrapped into a span element. That's why the following logic has been implemented:
const el = [...line.childNodes].find(({ textContent }) => {
if (charCount === d.start_char) return true;
charCount += textContent.length;
return false;
});
We receive start_char from the backend and get the Nth element using that number. However, the elements are not always wrapped into separate spans (like in this example):
<code>
<span id="LC59" lang="go" data-testid="content" class="line code-navigation-line hll">
<span class=""></span>
<span class="hljs-keyword">if</span>
<span class=""></span>
<span class="cursor-pointer code-navigation js-code-navigation">c.cfg.Server.ClientAliveInterval</span>
<span class=""></span>
<span class="">></span>
<span class=""></span>
<span class="hljs-number">0</span>
<span class=""></span>
<span class="">{</span>
</span>
</code>
However, the backend returns the following points for code units of c.cfg.Server.ClientAliveInterval:
-
{"start_line"=>58, "start_char"=>4}forc -
{"start_line"=>58, "start_char"=>6}forcfg -
{"start_line"=>58, "start_char"=>10}forServer -
{"start_line"=>58, "start_char"=>17}forClientAliveInterval
The problem should be fixed on the frontend, but backend may need to return either end_char or length to mark the end of a code unit.
Edited by Igor Drozdov