mirror of
https://github.com/wavetermdev/waveterm.git
synced 2025-01-07 19:28:44 +01:00
for non-relative resolves, return nil if the number is out of range
This commit is contained in:
parent
582cd807a8
commit
29205ba586
@ -162,6 +162,8 @@ func resolveByPosition(isNumeric bool, allItems []ResolveItem, curId string, pos
|
||||
}
|
||||
}
|
||||
finalPos = curIdx + posArg.Pos
|
||||
finalPos = boundInt(finalPos, len(items), posArg.IsWrap)
|
||||
return &items[finalPos-1]
|
||||
} else if isNumeric {
|
||||
// these resolve items have a "Num" set that should be used to look up non-relative positions
|
||||
// use allItems for numeric resolve
|
||||
@ -174,9 +176,11 @@ func resolveByPosition(isNumeric bool, allItems []ResolveItem, curId string, pos
|
||||
} else {
|
||||
// non-numeric means position is just the index
|
||||
finalPos = posArg.Pos
|
||||
if finalPos <= 0 || finalPos > len(items) {
|
||||
return nil
|
||||
}
|
||||
return &items[finalPos-1]
|
||||
}
|
||||
finalPos = boundInt(finalPos, len(items), posArg.IsWrap)
|
||||
return &items[finalPos-1]
|
||||
}
|
||||
|
||||
func resolveRemoteArg(remoteArg string) (*sstore.RemotePtrType, error) {
|
||||
|
Loading…
Reference in New Issue
Block a user