File tree Expand file tree Collapse file tree 2 files changed +28
-3
lines changed Expand file tree Collapse file tree 2 files changed +28
-3
lines changed Original file line number Diff line number Diff line change @@ -95,7 +95,10 @@ Activity Resolver Table:
9595Packages:
9696 Package [com.google.foo] (ffffffc):
9797 userId=12345
98- primaryCpuAbi=armeabi-v7a
98+ *** extra whitespace on next line is for testing https://github.com/google/agi/issues/1077 ***
99+ *** Do not remove it, doing so will make the tests fail ***
100+
101+ primaryCpuAbi=armeabi-v7a
99102 secondaryCpuAbi=null
100103 versionCode=902107 minSdk=14 targetSdk=15
101104 flags=[ HAS_CODE ALLOW_CLEAR_USER_DATA ALLOW_BACKUP ]
Original file line number Diff line number Diff line change @@ -211,6 +211,7 @@ func (t *treeNode) find(name string) *treeNode {
211211
212212func parseTabbedTree (str string ) * treeNode {
213213 head := & treeNode {depth : - 1 }
214+ extraDepth := 0
214215 for _ , line := range strings .Split (str , "\n " ) {
215216 line = strings .TrimRight (line , "\r " )
216217 if line == "" {
@@ -219,14 +220,35 @@ func parseTabbedTree(str string) *treeNode {
219220
220221 // Calculate the line's depth
221222 depth := 0
222- for i , r := range line {
223+ for _ , r := range line {
223224 if r == ' ' {
224225 depth ++
225226 } else {
226- line = line [i :]
227227 break
228228 }
229229 }
230+ line = line [depth :]
231+
232+ if line == "" {
233+ // A line containing only whitespace probably comes from an extra newline
234+ // character being printed before the intended line. So, add the depth that
235+ // would have resulted from this empty line to the next line. Example with
236+ // front spaces shown as '_':
237+ // ...
238+ // Known Packages:
239+ // _ Package [foo]:
240+ // __
241+ //Package categories:
242+ // ___ category bar
243+ // ...
244+ // In the above example "Package categories" was meant to be indented by
245+ // two spaces, which are present on the previous line.
246+ extraDepth += depth
247+ continue
248+ }
249+
250+ depth += extraDepth
251+ extraDepth = 0
230252
231253 // Find the insertion point
232254 for {
You can’t perform that action at this time.
0 commit comments