Comments (16)
Here's the raw data that leads to the error (for the C example):
{
"start": {
"line_num": 2,
"column_num": 1,
"filepath": "/home/bstaletic/work/test/foo.cpp"
},
"end": {
"line_num": 3,
"column_num": 11,
"filepath": "/home/bstaletic/work/test/foo.cpp"
}
}
[
{
"id": "4",
"col": "1",
"type_bufnr": "0",
"end": "0",
"type": "YcmWarningProperty",
"length": "13",
"start": "1"
},
{
"id": "3",
"col": "1",
"type_bufnr": "0",
"end": "0",
"type": "YcmWarningProperty",
"length": "13",
"start": "1"
}
]
In GetTextPropertyForDiag()
we end up subtracting end column of next line from start column of this line, leading to bad length calculation.
@Aster89 Try this patch:
diff --git a/python/ycm/vimsupport.py b/python/ycm/vimsupport.py
index 14798145..61852477 100644
--- a/python/ycm/vimsupport.py
+++ b/python/ycm/vimsupport.py
@@ -284,7 +284,16 @@ def GetTextPropertyForDiag( buffer_number, line_number, diag ):
range = diag[ 'location_extent' ]
start = range[ 'start' ]
end = range[ 'end' ]
- length = end[ 'column_num' ] - start[ 'column_num' ]
+ start_line = start[ 'line_num' ]
+ end_line = end[ 'line_num' ]
+ if start_line == end_line:
+ length = end[ 'column_num' ] - start[ 'column_num' ]
+ elif start_line == line_number:
+ length = len( vim.buffers[ buffer_number ][ line_number - 1 ] ) - start[ 'column_num' ] + 2
+ elif end_line == line_num:
+ length = end[ 'column_num' ] - 1
+ else:
+ length = len( vim.buffers[ buffer_number ][ line_number - 1 ] )
if diag[ 'kind' ] == 'ERROR':
property_name = 'YcmErrorProperty'
else:
from youcompleteme.
This time it was not my oversight! Here's the patch:
diff --git a/python/ycm/youcompleteme.py b/python/ycm/youcompleteme.py
index a09b2ef2..76c8c0a5 100644
--- a/python/ycm/youcompleteme.py
+++ b/python/ycm/youcompleteme.py
@@ -867,7 +867,7 @@ class YouCompleteMe:
'textpropid': prop[ 'id' ],
'textprop': prop[ 'type' ],
} )
- options.pop( 'col' )
+ options.pop( 'col', None )
vim.eval( f'{ popup_func }( { json.dumps( lines ) }, '
f'{ json.dumps( options ) } )' )
else:
Tests incoming.
from youcompleteme.
What happens?
from youcompleteme.
I missed quite an important info! Updated.
from youcompleteme.
@Aster89 Itl think your html formatting got a little screwed. What is the 5th step exactly?
from youcompleteme.
@bstaletic , yep, <kbd>\<kbd>
instead of <kbd>\\<kbd>
is the culprit. Corrected now.
from youcompleteme.
I've hit this again with an Haskell file. Specifically, the following erronous (for whatever reason, ahah) XMonad config file causes the same error as above, when asking diagnostics from the line with def
(all is fine from the following 5 lines):
import XMonad
import qualified XMonad.Prompt as P
main :: IO ()
main = xmonad def
{ terminal = "urxvt"
, modMask = mod4Mask
, borderWidth = 3
, P.borderColor = undefined
}
from youcompleteme.
Managed to repro! Sorry for taking so long. Looks like GetTextPropertyForDiag()
does not take into account multi-line diags.
from youcompleteme.
The popup placement is very weird on my computer. Though I thing that has something to do with my vim version.
from youcompleteme.
The patch works!
from youcompleteme.
I've hit another similar error (I'm now on 2b33bf3) with this Haskell code
import Data.Function
getCharAndProcess :: IO ()
getCharAndProcess = do
fix $ \recurse previous -> do
c <- getChar -- on this line
return previous -- or on this line
Trying to show the detailed diag popup on one of the two lines with a comment results in the error above.
from youcompleteme.
Damnit... I did not realize that the previous fix had a sneaky assumption - all mutliline diagnostics start at line 1.
Here's the patch:
diff --git a/python/ycm/vimsupport.py b/python/ycm/vimsupport.py
index ca603206..826a5b59 100644
--- a/python/ycm/vimsupport.py
+++ b/python/ycm/vimsupport.py
@@ -288,18 +288,22 @@ def GetTextPropertyForDiag( buffer_number, line_number, diag ):
end_line = end[ 'line_num' ]
if start_line == end_line:
length = end[ 'column_num' ] - start[ 'column_num' ]
+ column = start[ 'column_num' ]
elif start_line == line_number:
# -1 switches to 0-based indexing.
current_line_len = len( vim.buffers[ buffer_number ][ line_number - 1 ] )
# +2 includes the start columnand accounts for properties at the end of line
# covering \n as well.
length = current_line_len - start[ 'column_num' ] + 2
+ column = start[ 'column_num' ]
elif end_line == line_number:
length = end[ 'column_num' ] - 1
+ column = 1
else:
# -1 switches to 0-based indexing.
# +1 accounts for properties at the end of line covering \n as well.
length = len( vim.buffers[ buffer_number ][ line_number - 1 ] ) + 1
+ column = 1
if diag[ 'kind' ] == 'ERROR':
property_name = 'YcmErrorProperty'
else:
@@ -309,7 +313,7 @@ def GetTextPropertyForDiag( buffer_number, line_number, diag ):
f'{{ "bufnr": { buffer_number }, '
f'"types": [ "{ property_name }" ] }} )' )
return next( filter(
- lambda p: start[ 'column_num' ] == int( p[ 'col' ] ) and
+ lambda p: column == int( p[ 'col' ] ) and
length == int( p[ 'length' ] ),
vim_props ) )
else:
I'll make a pull request after adjusting the tests.
from youcompleteme.
Sorry for the notification. I had updated YCM but forgotten to close and reopen Vim :D
from youcompleteme.
Actually I have indeed found repro steps for a similar error.
The repros are essentially identical to those in my previous message, except that the following one-line Haskell file should be used instead:
foo txt = (tail txt, tail txt)
The error (again, upon trying to show the detailed diag in the popup) is this:
Error detected while processing function <SNR>32_ShowDetailedDiagnostic:
line 3:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/home/enrico/.vim/plugged/YouCompleteMe/python/ycm/youcompleteme.py", line 870, in ShowDetailedDiagnostic
options.pop( 'col' )
KeyError: 'col'
from youcompleteme.
Yes, the above fixes the issue.
from youcompleteme.
Fixed in #4219
from youcompleteme.
Related Issues (20)
- OpenBSD Compile Failure on 6.8+ HOT 7
- OpenBSD 7.4 Python module fails to load HOT 2
- [question] Is it possible to modify the format of virtual-text? HOT 2
- The completion results provided by YCM with the first 'ctrl+space' are different from those with the second 'ctrl+space'. HOT 2
- C++17 filesystem library missing in Sonoma HOT 2
- GoToDefinition splits instead of replacing buffer if modified but opened elsewhere HOT 4
- java completer reports errors on clean workspace until any dummy change made HOT 3
- Install.py stall on raspberry pi HOT 4
- hacked account
- [question/feature request] Insert trailing semicolon for continue, return HOT 2
- ycm compile failed, please help me. HOT 3
- ycmd shutdowns immediately with segmentation fault
- BrokenPipeError: [Errno 32] Broken pipe? HOT 1
- Fix punctuation and clarity in README and LICENSE
- Compilation on FreeBSD 14 fails HOT 2
- remaps for insert mode are inflicted by this plugin HOT 2
- Compile issue on FreeBSD13.3 release, absl_time_zone.dir/all => Error code 2 HOT 10
- 'go get' is no longer supported outside a module. HOT 10
- Errors While Loading Plugin in Vim HOT 7
- virtual-text not work in nvim HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from youcompleteme.