d2lsp: getboardatposition edge case
This commit is contained in:
parent
10b0190f9b
commit
5b13afa6da
2 changed files with 18 additions and 0 deletions
|
|
@ -143,6 +143,11 @@ func getBoardPathAtPosition(m d2ast.Map, currPath []string, pos d2ast.Position)
|
||||||
return deeperPath
|
return deeperPath
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// We're in between boards, e.g. layers.x.scenarios
|
||||||
|
// Which means, there's no board at this position
|
||||||
|
if len(newPath)%2 == 1 {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
// Nothing deeper matched but we're in this map's range, return current path
|
// Nothing deeper matched but we're in this map's range, return current path
|
||||||
return newPath
|
return newPath
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -291,6 +291,19 @@ layers: {
|
||||||
position: d2ast.Position{Line: 3, Column: 2},
|
position: d2ast.Position{Line: 3, Column: 2},
|
||||||
want: []string{"layers", "basic"},
|
want: []string{"layers", "basic"},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: "cursor in between",
|
||||||
|
fs: map[string]string{
|
||||||
|
"index.d2": `
|
||||||
|
layers: {
|
||||||
|
basic: {
|
||||||
|
}
|
||||||
|
}`,
|
||||||
|
},
|
||||||
|
path: "index.d2",
|
||||||
|
position: d2ast.Position{Line: 2, Column: 2},
|
||||||
|
want: nil,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, tt := range tests {
|
for _, tt := range tests {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue