From 4f0bac791a3d8ae198d8bbbbed29410d3d7d3d7c Mon Sep 17 00:00:00 2001 From: Miran Date: Fri, 12 Mar 2021 15:34:42 +0100 Subject: [PATCH] fix #12155, improve nimpretty's handling of pragmas (#17353) --- compiler/layouter.nim | 3 ++- nimpretty/tests/exhaustive.nim | 4 ++++ nimpretty/tests/expected/exhaustive.nim | 5 +++++ 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/compiler/layouter.nim b/compiler/layouter.nim index c603c16ffc..ec9db6aad5 100644 --- a/compiler/layouter.nim +++ b/compiler/layouter.nim @@ -514,7 +514,8 @@ proc emitTok*(em: var Emitter; L: Lexer; tok: Token) = (not em.wasExportMarker or tok.tokType == tkCurlyDotLe): wrSpace em wr(em, $tok.tokType, ltSomeParLe) - rememberSplit(splitParLe) + if tok.tokType != tkCurlyDotLe: + rememberSplit(splitParLe) of closedPars: wr(em, $tok.tokType, ltSomeParRi) of tkColonColon: diff --git a/nimpretty/tests/exhaustive.nim b/nimpretty/tests/exhaustive.nim index 83f4f04c3d..30cfc47a98 100644 --- a/nimpretty/tests/exhaustive.nim +++ b/nimpretty/tests/exhaustive.nim @@ -843,3 +843,7 @@ type SpinnyEvent2 = tuple kind: EventKind payload: string + + +proc hid_open*(vendor_id: cushort; product_id: cushort; serial_number: cstring): ptr HidDevice {. + importc: "hid_open", dynlib: hidapi.} diff --git a/nimpretty/tests/expected/exhaustive.nim b/nimpretty/tests/expected/exhaustive.nim index 382722ea79..82927a11cf 100644 --- a/nimpretty/tests/expected/exhaustive.nim +++ b/nimpretty/tests/expected/exhaustive.nim @@ -856,3 +856,8 @@ type SpinnyEvent2 = tuple kind: EventKind payload: string + + +proc hid_open*(vendor_id: cushort; product_id: cushort; + serial_number: cstring): ptr HidDevice {. + importc: "hid_open", dynlib: hidapi.}