// ComputeTextEdits computes text edits that are required to
// change the `unformatted` to the `formatted` text.
489560
func ComputeTextEdits(unformatted string, formatted string) []lsp.TextEdit {
	// LSP wants a list of TextEdits. We use difflib to compute a
	// non-naive TextEdit. Originally we returned an edit which deleted
	// everything followed by inserting everything. This leads to a poor
	// experience in vscode.
	unformattedLines := strings.Split(unformatted, "\n")
	formattedLines := strings.Split(formatted, "\n")
	m := difflib.NewMatcher(unformattedLines, formattedLines)
	var edits []lsp.TextEdit
	for _, op := range m.GetOpCodes() {
		switch op.Tag {
		case 'r': // 'r' (replace):  a[i1:i2] should be replaced by b[j1:j2]
			edits = append(edits, lsp.TextEdit{
				Range: lsp.Range{
					Start: lsp.Position{
						Line: op.I1,
					},
					End: lsp.Position{
						Line: op.I2,
					},
				},
				NewText: strings.Join(formattedLines[op.J1:op.J2], "\n") + "\n",
			})
		case 'd': // 'd' (delete):   a[i1:i2] should be deleted, j1==j2 in this case.
			edits = append(edits, lsp.TextEdit{
				Range: lsp.Range{
					Start: lsp.Position{
						Line: op.I1,
					},
					End: lsp.Position{
						Line: op.I2,
					},
				},
			})
		case 'i': // 'i' (insert):   b[j1:j2] should be inserted at a[i1:i1], i1==i2 in this case.
			edits = append(edits, lsp.TextEdit{
				Range: lsp.Range{
					Start: lsp.Position{
						Line: op.I1,
					},
					End: lsp.Position{
						Line: op.I1,
					},
				},
				NewText: strings.Join(formattedLines[op.J1:op.J2], "\n") + "\n",
			})
		}
	}

	return edits
}
225605
func (s *NoteUpdate) SetText(v string) *NoteUpdate {
	s.Text = &v
	return s
}
1274129
func (f *file) lintTypeDoc(t *ast.TypeSpec, doc *ast.CommentGroup) {
	if !ast.IsExported(t.Name.Name) {
		return
	}
	if doc == nil {
		f.errorf(t, 1, link(docCommentsLink), category("comments"), "exported type %v should have comment or be unexported", t.Name)
		return
	}

	s := doc.Text()
	articles := [...]string{"A", "An", "The"}
	for _, a := range articles {
		if strings.HasPrefix(s, a+" ") {
			s = s[len(a)+1:]
			break
		}
	}
	if !strings.HasPrefix(s, t.Name.Name+" ") {
		f.errorf(doc, 1, link(docCommentsLink), category("comments"), `comment on exported type %v should be of the form "%v ..." (with optional leading article)`, t.Name, t.Name)
	}
}
359730
func (scaledFont *ScaledFont) TextExtents(utf8 string, extents *TextExtents) {
	c_utf8 := C.CString(utf8)
	defer C.free(unsafe.Pointer(c_utf8))
	C.cairo_scaled_font_text_extents(scaledFont.Ptr, c_utf8, (*C.cairo_text_extents_t)(unsafe.Pointer(extents)))
	if err := scaledFont.status(); err != nil {
		panic(err)
	}
}
936389
func computeOwnedRWsets(block *common.Block, blockPvtData util.PvtDataCollections) (rwsetByKeys, error) {
	lastBlockSeq := len(block.Data.Data) - 1

	ownedRWsets := make(map[rwSetKey][]byte)
	for _, txPvtData := range blockPvtData {
		if lastBlockSeq < int(txPvtData.SeqInBlock) {
			logger.Warningf("Claimed SeqInBlock %d but block has only %d transactions", txPvtData.SeqInBlock, len(block.Data.Data))
			continue
		}
		env, err := utils.GetEnvelopeFromBlock(block.Data.Data[txPvtData.SeqInBlock])
		if err != nil {
			return nil, err
		}
		payload, err := utils.GetPayload(env)
		if err != nil {
			return nil, err
		}

		chdr, err := utils.UnmarshalChannelHeader(payload.Header.ChannelHeader)
		if err != nil {
			return nil, err
		}
		for _, ns := range txPvtData.WriteSet.NsPvtRwset {
			for _, col := range ns.CollectionPvtRwset {
				computedHash := hex.EncodeToString(util2.ComputeSHA256(col.Rwset))
				ownedRWsets[rwSetKey{
					txID:       chdr.TxId,
					seqInBlock: txPvtData.SeqInBlock,
					collection: col.CollectionName,
					namespace:  ns.Namespace,
					hash:       computedHash,
				}] = col.Rwset
			} // iterate over collections in the namespace
		} // iterate over the namespaces in the WSet
	} // iterate over the transactions in the block
	return ownedRWsets, nil
}
121564
func (s *IndexField) SetTextArrayOptions(v *TextArrayOptions) *IndexField {
	s.TextArrayOptions = v
	return s
}
538044
func initContextLUTs() {
	for i := 0; i < 256; i++ {
		for m := 0; m < numContextModes; m++ {
			base := m << 8

			// Operations performed here are specified in RFC section 7.1.
			switch m {
			case contextLSB6:
				contextP1LUT[base+i] = byte(i) & 0x3f
				contextP2LUT[base+i] = 0
			case contextMSB6:
				contextP1LUT[base+i] = byte(i) >> 2
				contextP2LUT[base+i] = 0
			case contextUTF8:
				contextP1LUT[base+i] = contextLUT0[byte(i)]
				contextP2LUT[base+i] = contextLUT1[byte(i)]
			case contextSigned:
				contextP1LUT[base+i] = contextLUT2[byte(i)] << 3
				contextP2LUT[base+i] = contextLUT2[byte(i)]
			default:
				panic("unknown context mode")
			}
		}
	}
}
899128
func (c *Context) EditMessagesTextWithEventID(eventID string, text string) (edited int, err error) {
	var messages []OutgoingMessage
	//update MAX_MSGS_TO_UPDATE_WITH_EVENTID last bot messages
	c.db.C("messages").Find(bson.M{"botid": c.Bot().ID, "eventid": eventID}).Sort("-_id").Limit(MaxMsgsToUpdateWithEventID).All(&messages)
	for _, message := range messages {
		err = c.EditMessageText(&message, text)
		if err != nil {
			c.Log().WithError(err).WithField("eventid", eventID).Error("EditMessagesTextWithEventID")
		} else {
			edited++
		}
	}
	return edited, err
}
840370
func (m *matcher) computeNext(d *dstate, c int) *dstate {
	this, next := &m.z1, &m.z2
	this.dec(d.enc)

	// compute flags in effect before c
	flag := syntax.EmptyOp(0)
	if this.flag&flagBOL != 0 {
		flag |= syntax.EmptyBeginLine
	}
	if this.flag&flagBOT != 0 {
		flag |= syntax.EmptyBeginText
	}
	if this.flag&flagWord != 0 {
		if !isWordByte(c) {
			flag |= syntax.EmptyWordBoundary
		} else {
			flag |= syntax.EmptyNoWordBoundary
		}
	} else {
		if isWordByte(c) {
			flag |= syntax.EmptyWordBoundary
		} else {
			flag |= syntax.EmptyNoWordBoundary
		}
	}
	if c == '\n' {
		flag |= syntax.EmptyEndLine
	}
	if c == endText {
		flag |= syntax.EmptyEndLine | syntax.EmptyEndText
	}

	// re-expand queue using new flags.
	// TODO: only do this when it matters
	// (something is gating on word boundaries).
	m.stepEmpty(&this.q, &next.q, flag)
	this, next = next, this

	// now compute flags after c.
	flag = 0
	next.flag = 0
	if c == '\n' {
		flag |= syntax.EmptyBeginLine
		next.flag |= flagBOL
	}
	if isWordByte(c) {
		next.flag |= flagWord
	}

	// re-add start, process rune + expand according to flags.
	if m.stepByte(&this.q, &next.q, c, flag) {
		return &dmatch
	}
	return m.cache(next)
}
31634
func ParseDate(sc *stmtctx.StatementContext, str string) (Time, error) {
	// date has no fractional seconds precision
	return ParseTime(sc, str, mysql.TypeDate, MinFsp)
}
1147329
func (keyboard *InlineKeyboard) EditText(buttonData string, newText string) {
	for i, buttonsRow := range keyboard.Buttons {
		for j, button := range buttonsRow {
			if button.Data == buttonData {
				keyboard.Buttons[i][j].Text = newText
				return
			}
		}
	}
}
208220
func (t *OSesTable) computeChanges(c context.Context, oses []*config.OS) {
	cfgs := make(map[string]*OS, len(oses))
	for _, cfg := range oses {
		cfgs[cfg.Name] = &OS{
			OS: config.OS{
				Name:        cfg.Name,
				Description: cfg.Description,
			},
		}
	}

	for _, os := range t.current {
		if cfg, ok := cfgs[os.Name]; ok {
			// Operating system found in the config.
			if t.needsUpdate(os, cfg) {
				// Operating system doesn't match the config.
				cfg.Id = os.Id
				t.updates = append(t.updates, cfg)
			}
			// Record that the operating system config has been seen.
			delete(cfgs, cfg.Name)
		} else {
			// Operating system not found in the config.
			t.removals = append(t.removals, os)
		}
	}

	// Operating systems remaining in the map are present in the config but not the database.
	// Iterate deterministically over the slice to determine which operating systems need to be added.
	for _, cfg := range oses {
		if os, ok := cfgs[cfg.Name]; ok {
			t.additions = append(t.additions, os)
		}
	}
}
568556
func IsEditRecipients(ctx context.Context) bool {
	bv, ok := ctx.Value(ctxKeyEditRecipients).(bool)
	if !ok {
		return false
	}
	return bv
}
659535
func NewText(tags core.TagSlice) (*Text, error) {
	text := new(Text)

	// set default
	text.RelativeXScale = 1.0
	text.StyleName = "STANDARD"
	text.ExtrusionDirection = core.Point{X: 0.0, Y: 0.0, Z: 1.0}

	text.InitBaseEntityParser()
	text.Update(map[int]core.TypeParser{
		1:  core.NewStringTypeParserToVar(&text.Value),
		7:  core.NewStringTypeParserToVar(&text.StyleName),
		10: core.NewFloatTypeParserToVar(&text.FirstAlignmentPoint.X),
		20: core.NewFloatTypeParserToVar(&text.FirstAlignmentPoint.Y),
		30: core.NewFloatTypeParserToVar(&text.FirstAlignmentPoint.Z),
		39: core.NewFloatTypeParserToVar(&text.Thickness),
		40: core.NewFloatTypeParserToVar(&text.Height),
		41: core.NewFloatTypeParserToVar(&text.RelativeXScale),
		50: core.NewFloatTypeParserToVar(&text.Rotation),
		51: core.NewFloatTypeParserToVar(&text.ObliqueAngle),
		71: core.NewIntTypeParser(func(flags int) {
			text.MirroredX = flags&backwardTextBit != 0
			text.MirroredY = flags&upsideDownTextBit != 0
		}),
		72: core.NewIntTypeParser(func(value int) {
			text.HorizontalJustification = HorizontalTextJustification(value)
		}),
		73: core.NewIntTypeParser(func(value int) {
			text.VerticalJustification = VerticalTextJustification(value)
		}),
		11:  core.NewFloatTypeParserToVar(&text.SecondAlignmentPoint.X),
		21:  core.NewFloatTypeParserToVar(&text.SecondAlignmentPoint.Y),
		31:  core.NewFloatTypeParserToVar(&text.SecondAlignmentPoint.Z),
		210: core.NewFloatTypeParserToVar(&text.ExtrusionDirection.X),
		220: core.NewFloatTypeParserToVar(&text.ExtrusionDirection.Y),
		230: core.NewFloatTypeParserToVar(&text.ExtrusionDirection.Z),
	})

	err := text.Parse(tags)
	return text, err
}
362565
func (b *Btelegram) handleEdit(msg *config.Message, chatid int64) (string, error) {
	msgid, err := strconv.Atoi(msg.ID)
	if err != nil {
		return "", err
	}
	if strings.ToLower(b.GetString("MessageFormat")) == HTMLNick {
		b.Log.Debug("Using mode HTML - nick only")
		msg.Text = html.EscapeString(msg.Text)
	}
	m := tgbotapi.NewEditMessageText(chatid, msgid, msg.Username+msg.Text)
	switch b.GetString("MessageFormat") {
	case HTMLFormat:
		b.Log.Debug("Using mode HTML")
		m.ParseMode = tgbotapi.ModeHTML
	case "Markdown":
		b.Log.Debug("Using mode markdown")
		m.ParseMode = tgbotapi.ModeMarkdown
	}
	if strings.ToLower(b.GetString("MessageFormat")) == HTMLNick {
		b.Log.Debug("Using mode HTML - nick only")
		m.ParseMode = tgbotapi.ModeHTML
	}
	_, err = b.c.Send(m)
	if err != nil {
		return "", err
	}
	return "", nil
}
566829
func NewText(f *Font, scaleMin, scaleMax float32) (t *Text) {
	t = &Text{}
	t.Font = f

	// text hover values
	// "resting state" of a text object is the min scale
	t.ScaleMin, t.ScaleMax = scaleMin, scaleMax
	t.SetScale(1)
	glfloat_size := int32(4)

	// stride of the buffered data
	xy_count := int32(2)
	stride := xy_count + int32(2)

	gl.GenVertexArrays(1, &t.vao)
	gl.GenBuffers(1, &t.vbo)
	gl.GenBuffers(1, &t.ebo)

	// vao
	gl.BindVertexArray(t.vao)

	// i think this call isnt necessary here
	// gl.ActiveTexture(gl.TEXTURE0)

	gl.BindTexture(gl.TEXTURE_2D, t.Font.textureID)

	// vbo
	// specify the buffer for which the VertexAttribPointer calls apply
	gl.BindBuffer(gl.ARRAY_BUFFER, t.vbo)

	gl.EnableVertexAttribArray(t.Font.centeredPositionAttribute)
	gl.VertexAttribPointer(
		t.Font.centeredPositionAttribute,
		2,
		gl.FLOAT,
		false,
		glfloat_size*stride,
		gl.PtrOffset(0),
	)

	gl.EnableVertexAttribArray(t.Font.uvAttribute)
	gl.VertexAttribPointer(
		t.Font.uvAttribute,
		2,
		gl.FLOAT,
		false,
		glfloat_size*stride,
		gl.PtrOffset(int(glfloat_size*xy_count)),
	)

	// ebo
	gl.BindBuffer(gl.ELEMENT_ARRAY_BUFFER, t.ebo)

	// i am guessing that order is important here
	gl.BindVertexArray(0)
	gl.BindBuffer(gl.ARRAY_BUFFER, 0)
	gl.BindBuffer(gl.ELEMENT_ARRAY_BUFFER, 0)
	return t
}
425148
func (n *Name) AddTextEntries(entries map[string]string) error {
	for f, v := range entries {
		if err := n.AddTextEntry(f, v); err != nil {
			return err
		}
	}
	return nil
}