nimpretty: fixes #10295
This commit is contained in:
parent
554908df0c
commit
447cc1ff09
4 changed files with 30 additions and 5 deletions
|
|
@ -106,11 +106,15 @@ proc softLinebreak(em: var Emitter, lit: string) =
|
||||||
# +2 because we blindly assume a comma or ' &' might follow
|
# +2 because we blindly assume a comma or ' &' might follow
|
||||||
if not em.inquote and em.col+lit.len+2 >= MaxLineLen:
|
if not em.inquote and em.col+lit.len+2 >= MaxLineLen:
|
||||||
if em.lastTok in splitters:
|
if em.lastTok in splitters:
|
||||||
|
# bug #10295, check first if even more indentation would help:
|
||||||
|
let spaces = em.indentLevel+moreIndent(em)
|
||||||
|
if spaces < em.col:
|
||||||
|
let oldPos = em.content.len # we can undo our changes if not benefitial
|
||||||
while em.content.len > 0 and em.content[em.content.high] == ' ':
|
while em.content.len > 0 and em.content[em.content.high] == ' ':
|
||||||
setLen(em.content, em.content.len-1)
|
setLen(em.content, em.content.len-1)
|
||||||
wr("\L")
|
wr("\L")
|
||||||
em.col = 0
|
em.col = 0
|
||||||
for i in 1..em.indentLevel+moreIndent(em): wr(" ")
|
for i in 1..spaces: wr(" ")
|
||||||
else:
|
else:
|
||||||
# search backwards for a good split position:
|
# search backwards for a good split position:
|
||||||
for a in mitems(em.altSplitPos):
|
for a in mitems(em.altSplitPos):
|
||||||
|
|
|
||||||
|
|
@ -96,6 +96,8 @@ proc getTok(p: var TParser) =
|
||||||
p.hasProgress = true
|
p.hasProgress = true
|
||||||
when defined(nimpretty2):
|
when defined(nimpretty2):
|
||||||
emitTok(p.em, p.lex, p.tok)
|
emitTok(p.em, p.lex, p.tok)
|
||||||
|
# skip the additional tokens that nimpretty needs but the parser has no
|
||||||
|
# interest in:
|
||||||
while p.tok.tokType == tkComment:
|
while p.tok.tokType == tkComment:
|
||||||
rawGetTok(p.lex, p.tok)
|
rawGetTok(p.lex, p.tok)
|
||||||
emitTok(p.em, p.lex, p.tok)
|
emitTok(p.em, p.lex, p.tok)
|
||||||
|
|
|
||||||
|
|
@ -366,3 +366,12 @@ proc fun4() =
|
||||||
var i = 0
|
var i = 0
|
||||||
while i<a.len and i<a.len:
|
while i<a.len and i<a.len:
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
||||||
|
# bug #10295
|
||||||
|
|
||||||
|
import osproc
|
||||||
|
let res = execProcess(
|
||||||
|
"echo | openssl s_client -connect example.com:443 2>/dev/null | openssl x509 -noout -dates")
|
||||||
|
|
||||||
|
let res = execProcess("echo | openssl s_client -connect example.com:443 2>/dev/null | openssl x509 -noout -dates")
|
||||||
|
|
|
||||||
|
|
@ -375,3 +375,13 @@ proc fun4() =
|
||||||
var i = 0
|
var i = 0
|
||||||
while i < a.len and i < a.len:
|
while i < a.len and i < a.len:
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
||||||
|
# bug #10295
|
||||||
|
|
||||||
|
import osproc
|
||||||
|
let res = execProcess(
|
||||||
|
"echo | openssl s_client -connect example.com:443 2>/dev/null | openssl x509 -noout -dates")
|
||||||
|
|
||||||
|
let res = execProcess(
|
||||||
|
"echo | openssl s_client -connect example.com:443 2>/dev/null | openssl x509 -noout -dates")
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue