MCPcopy
hub / github.com/micro-editor/micro / SliceStart

Function SliceStart

internal/util/util.go:142–157  ·  view source on GitHub ↗

SliceStart returns a byte slice where the index is a rune index Slices off the end of the slice

(slc []byte, index int)

Source from the content-addressed store, hash-verified

140// SliceStart returns a byte slice where the index is a rune index
141// Slices off the end of the slice
142func SliceStart(slc []byte, index int) []byte {
143 len := len(slc)
144 i := 0
145 totalSize := 0
146 for totalSize < len {
147 if i >= index {
148 return slc[:totalSize]
149 }
150
151 _, _, size := DecodeCharacter(slc[totalSize:])
152 totalSize += size
153 i++
154 }
155
156 return slc[:totalSize]
157}
158
159// SliceStartStr is the same as SliceStart but for strings
160func SliceStartStr(str string, index int) string {

Callers 7

CommandCompleteMethod · 0.92
BackspaceMethod · 0.92
OptionValueCompleteFunction · 0.92
PluginCompleteFunction · 0.92
findLineParamsFunction · 0.92
GetWordMethod · 0.92
GetArgMethod · 0.92

Calls 1

DecodeCharacterFunction · 0.70

Tested by

no test coverage detected