Closed mcserep closed 9 months ago
@mdeme01 If you have time, could you please pinpoint the relevant code segment, so we could fix this easier? Thanks!
@mdeme01 If you have time, could you please pinpoint the relevant code segment, so we could fix this easier? Thanks!
The highlighting is done based on the returned position (line, column) of the ast node. (getCppAstNodeInfoByPosition
), and all of this happens in the codemirror-editor.tsx
component, in the handleAstNodeSelect and dispatchSelection functions.
First, we check the position of the clicked node using CodeMirror's view.state
here. From this we can get the ast node info with the getCppAstNodeInfoByPosition
method, the response info will contain the ast node's position (line, column). Then we call CodeMirror's editor.dispatch method with the calculated anchor and head properties.
The highlighting of all other matched text might be related to the newer version of CodeMirror (- I used 6, the old one used 5 if i'm not mistaken.), as I implemented the selection the same way as in the old UI. Maybe there is a flag somewhere at the selection dispatch, but unfortunately, the CodeMirror documentation is really vague.
It seems that when a symbol (e.g. a variable) is clicked on the new frontend, the highlighting is not done based on the returned symbols by the backed, but instead some kind of text-based highlighting is performed.
E.g. when I clicked the variable
p
inStrPair::GetStr()
(located intinyxml2.cpp
), all p characters were highlighted in the file: all p characters in other variables, in function names, in comments, etc.https://codecompass.net/demo/new/project/?workspaceId=TinyXML2&projectFileId=13444780443610084403&editorSelection=358%7C33%7C358%7C34&activeTab=1&languageNodeId=3578118573785437335&activeAccordion=Info+tree