Skip to content
This repository has been archived by the owner on Feb 1, 2019. It is now read-only.

Commit

Permalink
diagnostic.py: Check row and column number
Browse files Browse the repository at this point in the history
Row and column number should be zero-based integer, not null

Fixes #37
  • Loading branch information
li-boxuan committed Mar 31, 2018
1 parent 45d39b9 commit e3ae164
Showing 1 changed file with 21 additions and 5 deletions.
26 changes: 21 additions & 5 deletions coala_langserver/diagnostic.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,33 @@ def output_to_diagnostics(output):
origin = problem['origin']
real_message = '[{}] {}: {}'.format(section, origin, message)
for code in problem['affected_code']:
"""
Line position and character offset should be zero-based
according to LSP, but row number of coala is one-based.
Line position and character offset should be numbers.
"""
start_line = code['start']['line'] - 1
start_char = code['start']['column']
end_line = code['end']['line'] - 1
end_char = code['end']['column']
if start_line is None:
start_line = 0
if start_char is None:
start_char = 0
if end_line is None:
end_line = 0
if end_char is None:
end_char = 0
res.append({
'severity': severity,
'range': {
'start': {
# Trick: VS Code starts from 0?
'line': code['start']['line'] - 1,
'character': code['start']['column']
'line': start_line,
'character': start_char
},
'end': {
'line': code['end']['line'] - 1,
'character': code['end']['column']
'line': end_line,
'character': end_char
}
},
'source': 'coala',
Expand Down

0 comments on commit e3ae164

Please sign in to comment.