Skip to content

Commit 5cdfd96

Browse files
committed
Fix Position type
Unlike Nim's `uint32`, LSP's `uinteger` has an upper bound of 2^31-1. It breaks formatting in Sublime Text.
1 parent 4943401 commit 5cdfd96

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

protocol/types.nim

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,14 @@ import tables
55
type
66
OptionalSeq*[T] = Option[seq[T]]
77
OptionalNode* = Option[JsonNode]
8+
uinteger* = range[0 .. (1 shl 31 - 1)]
89

910
CancelParams* = ref object of RootObj
1011
id*: OptionalNode
1112

1213
Position* = ref object of RootObj
13-
line*: int # uinteger
14-
character*: int # uinteger
14+
line*: uinteger
15+
character*: uinteger
1516

1617
Range* = ref object of RootObj
1718
start*: Position
@@ -397,7 +398,7 @@ type
397398

398399
FoldingRangeClientCapabilities* = ref object of RootObj
399400
dynamicRegistration*: Option[bool]
400-
rangeLimit*: Option[int] # uinteger
401+
rangeLimit*: Option[uinteger]
401402
lineFoldingOnly*: Option[bool]
402403
foldingRangeKind*: Option[FoldingRangeClientCapabilities_foldingRangeKind]
403404
foldingRange*: Option[FoldingRangeClientCapabilities_foldingRange]

routes.nim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -733,7 +733,7 @@ proc format*(
733733

734734
let fullRange = Range(
735735
start: Position(line: 0, character: 0),
736-
`end`: Position(line: int(uint32.high), character: int(uint32.high)),
736+
`end`: Position(line: uinteger.high, character: uinteger.high)
737737
)
738738
debug "Formatting document", uri = uri, formattedText = formattedText
739739
some TextEdit(range: fullRange, newText: formattedText)

0 commit comments

Comments
 (0)