mirror of
https://github.com/ddidderr/wuffs.git
synced 2026-11-25 16:55:11 +01:00
wuffsfmt: indent with 4 spaces (not a tab)
This commit is contained in:
1 parent
9c03b8c71d
commit
f5eb38d76e
2 files changed
+13
-7
No files matched your search
+2
-1
@@ -6,7 +6,8 @@
|
|||||||
The dot points below probably aren't of interest unless you're _writing_ Wuffs
|
The dot points below probably aren't of interest unless you're _writing_ Wuffs
|
||||||
code (instead of writing C/C++ code that _uses_ Wuffs' standard library).
|
code (instead of writing C/C++ code that _uses_ Wuffs' standard library).
|
||||||
|
|
||||||
- `wuffsfmt` double-indents hanging lines.
|
- `wuffsfmt` double-indents hanging lines and each indent is now 4 spaces (not
|
||||||
|
a tab).
|
||||||
|
|
||||||
|
|
||||||
## 2023-04-08 version 0.3.3
|
## 2023-04-08 version 0.3.3
|
||||||
|
|||||||
+11
-6
@@ -294,13 +294,18 @@ func appendNum(buf []byte, s string) []byte {
|
|||||||
return buf
|
return buf
|
||||||
}
|
}
|
||||||
|
|
||||||
func appendTabs(buf []byte, n int) []byte {
|
func appendTabs(buf []byte, nTabs int) []byte {
|
||||||
if n > 0 {
|
nSpaces := 4 * nTabs // Hard-code 4 spaces per tab.
|
||||||
const tabs = "\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t"
|
if nSpaces > 0 {
|
||||||
for ; n > len(tabs); n -= len(tabs) {
|
const spaces = "" + // 256 spaces.
|
||||||
buf = append(buf, tabs...)
|
" " +
|
||||||
|
" " +
|
||||||
|
" " +
|
||||||
|
" "
|
||||||
|
for ; nSpaces > len(spaces); nSpaces -= len(spaces) {
|
||||||
|
buf = append(buf, spaces...)
|
||||||
}
|
}
|
||||||
buf = append(buf, tabs[:n]...)
|
buf = append(buf, spaces[:nSpaces]...)
|
||||||
}
|
}
|
||||||
return buf
|
return buf
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user