| 30 | } |
| 31 | |
| 32 | func applyDocsRequestTarget(requests []*docs.Request, target docsRequestTarget) { |
| 33 | for _, req := range requests { |
| 34 | if req == nil { |
| 35 | continue |
| 36 | } |
| 37 | if req.InsertText != nil { |
| 38 | if req.InsertText.Location != nil { |
| 39 | req.InsertText.Location.TabId = target.TabID |
| 40 | req.InsertText.Location.SegmentId = target.SegmentID |
| 41 | forceZeroLocationIndex(req.InsertText.Location) |
| 42 | } |
| 43 | if req.InsertText.EndOfSegmentLocation != nil { |
| 44 | req.InsertText.EndOfSegmentLocation.TabId = target.TabID |
| 45 | req.InsertText.EndOfSegmentLocation.SegmentId = target.SegmentID |
| 46 | } |
| 47 | } |
| 48 | for _, location := range docsRequestLocations(req) { |
| 49 | location.TabId = target.TabID |
| 50 | location.SegmentId = target.SegmentID |
| 51 | forceZeroLocationIndex(location) |
| 52 | } |
| 53 | for _, targetRange := range docsRequestRanges(req) { |
| 54 | targetRange.TabId = target.TabID |
| 55 | targetRange.SegmentId = target.SegmentID |
| 56 | forceZeroRangeStart(targetRange) |
| 57 | } |
| 58 | } |
| 59 | } |
| 60 | |
| 61 | func forceZeroLocationIndex(location *docs.Location) { |
| 62 | if location != nil && location.Index == 0 && !docsContainsString(location.ForceSendFields, "Index") { |