* fixes #20553; don't format code for stropping identifier * add tests * Update nimpretty/tests/expected/simple.nim
This commit is contained in:
parent
169d3fda00
commit
6082b9ea5d
3 changed files with 31 additions and 5 deletions
|
|
@ -551,11 +551,15 @@ proc emitTok*(em: var Emitter; L: Lexer; tok: Token) =
|
||||||
if not preventComment:
|
if not preventComment:
|
||||||
emitComment(em, tok, dontIndent = false)
|
emitComment(em, tok, dontIndent = false)
|
||||||
of tkIntLit..tkStrLit, tkRStrLit, tkTripleStrLit, tkGStrLit, tkGTripleStrLit, tkCharLit:
|
of tkIntLit..tkStrLit, tkRStrLit, tkTripleStrLit, tkGStrLit, tkGTripleStrLit, tkCharLit:
|
||||||
let lit = fileSection(em.config, em.fid, tok.offsetA, tok.offsetB)
|
if not em.inquote:
|
||||||
if endsInAlpha(em) and tok.tokType notin {tkGStrLit, tkGTripleStrLit}: wrSpace(em)
|
let lit = fileSection(em.config, em.fid, tok.offsetA, tok.offsetB)
|
||||||
em.lineSpan = countNewlines(lit)
|
if endsInAlpha(em) and tok.tokType notin {tkGStrLit, tkGTripleStrLit}: wrSpace(em)
|
||||||
if em.lineSpan > 0: calcCol(em, lit)
|
em.lineSpan = countNewlines(lit)
|
||||||
wr em, lit, ltLit
|
if em.lineSpan > 0: calcCol(em, lit)
|
||||||
|
wr em, lit, ltLit
|
||||||
|
else:
|
||||||
|
if endsInAlpha(em): wrSpace(em)
|
||||||
|
wr em, tok.literal, ltLit
|
||||||
of tkEof: discard
|
of tkEof: discard
|
||||||
else:
|
else:
|
||||||
let lit = if tok.ident != nil: tok.ident.s else: tok.literal
|
let lit = if tok.ident != nil: tok.ident.s else: tok.literal
|
||||||
|
|
|
||||||
|
|
@ -16,3 +16,14 @@ proc a() =
|
||||||
discard ## comment 3
|
discard ## comment 3
|
||||||
|
|
||||||
discard # comment 4
|
discard # comment 4
|
||||||
|
|
||||||
|
|
||||||
|
# bug #20553
|
||||||
|
|
||||||
|
let `'hello` = 12
|
||||||
|
echo `'hello`
|
||||||
|
|
||||||
|
|
||||||
|
proc `'u4`(n: string) =
|
||||||
|
# The leading ' is required.
|
||||||
|
discard
|
||||||
|
|
|
||||||
|
|
@ -16,3 +16,14 @@ proc a() =
|
||||||
discard## comment 3
|
discard## comment 3
|
||||||
|
|
||||||
discard # comment 4
|
discard # comment 4
|
||||||
|
|
||||||
|
|
||||||
|
# bug #20553
|
||||||
|
|
||||||
|
let `'hello` = 12
|
||||||
|
echo `'hello`
|
||||||
|
|
||||||
|
|
||||||
|
proc `'u4`(n: string) =
|
||||||
|
# The leading ' is required.
|
||||||
|
discard
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue