Closed yyjjl closed 6 years ago
Can you make a PR for the snippet?
The display seems weird...
Sometimes, the display is weird. But I have no time to find the reason recently.
Yes sometimes. It's very annoying
This hack seems to work
(forward-line (- (car start) last-line-number))
(forward-char (cdr start))
;; start of range
(setq range-start (point))
(setq last-line-number (car start))
(save-excursion
(forward-line (- (car end) (car start)))
(forward-char (cdr end))
;; end of range
(setq range-end (point)))
The hack does not work for this file https://github.com/cquery-project/cquery/blob/master/src/indexer.h
Are you using https://github.com/emacs-mirror/emacs/tree/feature/noverlay ?
No, I am using Emacs 25.3. The hack seems to work for me on cquery v2018-01-23.
Sometimes, the semantic highlighting on indexer.h, line 476 seems wired.
First time to open indexer.h
(.cquery_cached_index removed), I got (part of) message from cquery server as below. ( ) , .
are recognized as a type. But next time, the display was right.
{
"stableId" : 22,
"ranges" : [
{
"start" : {
"line" : 475,
"character" : 13
},
"end" : {
"character" : 14,
"line" : 475
}
},
{
"end" : {
"line" : 475,
"character" : 24
},
"start" : {
"line" : 475,
"character" : 22
}
},
{
"start" : {
"line" : 475,
"character" : 25
},
"end" : {
"character" : 26,
"line" : 475
}
},
{
"end" : {
"line" : 475,
"character" : 29
},
"start" : {
"character" : 28,
"line" : 475
}
}
],
"storage" : 0,
"kind" : 6,
"parentKind" : 0
}
line 476 of https://github.com/cquery-project/cquery/blob/master/src/indexer.h is indeed weird. The weirdness seems to start on line 135
I have reverted the sorting.
Line 135 -150 are display right in my Emacs. Is it possible that file content in cquery server doesn't match with buffer content in Emacs ?
No. If I use the reverted version (goto-char 1 + full forward-line), semantic highlighting looks correct. But that sorting + incremental forward-line approach sometimes makes bad rendering.
I will try to figure out why sorting is not working later.
cquery--publish-semantic-highlighting
is very slow becausecquery--read-range
callslsp--position-to-point
. It needs to walk from beginning of buffer to the given point on every call. If we can collect all ranges first and sort them by line number, only one pass is required to publish semantic highlighting.I wrote a simple example as below: