You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: text.go
    path of file: ./repos/gdlv/vendor/github.com/aarzilli/nucular
    
    the code of the file until where you have to start completion: package nucular

import (
	"image"
	"image/color"
	"math"
	"runtime"
	"time"
	"unicode"

	"golang.org/x/mobile/event/key"
	"golang.org/x
    
func (state *TextEditor) clamp() {
	/* make the selection/cursor state valid if client altered the string */
	if state.hasSelection() {
		if state.SelectStart > len(state.Buffer) {
			state.SelectStart = len(state.Buffer)
		}
		if state.SelectEnd > len(state.Buffer) {
			state.SelectEnd = len(state.Buffer)
		}

		/* if clamping forced them to be equal, move the cursor to match */
		if state.SelectStart == state.SelectEnd {
			state.Cursor = state.SelectStart
		}
	}

	if state.Cursor > len(state.Buffer) {
		state.Cursor = len(state.Buffer)
	}
}