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

Method LocFromVLoc

internal/display/softwrap.go:334–342  ·  view source on GitHub ↗

LocFromVLoc takes a visual location in the linewrapped buffer and returns the position in the buffer corresponding to this visual location.

(vloc VLoc)

Source from the content-addressed store, hash-verified

332// LocFromVLoc takes a visual location in the linewrapped buffer and returns
333// the position in the buffer corresponding to this visual location.
334func (w *BufWindow) LocFromVLoc(vloc VLoc) buffer.Loc {
335 if !w.Buf.Settings["softwrap"].(bool) {
336 tabsize := util.IntOpt(w.Buf.Settings["tabsize"])
337
338 x := util.GetCharPosInLine(w.Buf.LineBytes(vloc.Line), vloc.VisualX, tabsize)
339 return buffer.Loc{x, vloc.Line}
340 }
341 return w.getLocFromVLoc(vloc)
342}

Callers 1

LocFromVisualMethod · 0.95

Calls 4

getLocFromVLocMethod · 0.95
IntOptFunction · 0.92
GetCharPosInLineFunction · 0.92
LineBytesMethod · 0.65

Tested by

no test coverage detected