<commit_before>package main

import (
	"strings"
	"time"
	"unicode/utf8"

	"golang.org/x/mobile/event/lifecycle"
)

func updateTag() {
	old := string(tagWidget.ed.Contents())
	var user string
	if i := strings.Index(old, "|"); i > 0 {
		user = old[i+1:]
		old = old[:i+1]
	}

	var newParts []string
	if filename != "" {
		newParts = append(newParts, filename)
	}
	if mainWidget.ed.CanUndo() {
		newParts = append(newParts, "Undo")
	}
	if mainWidget.ed.CanRedo() {
		newParts = append(newParts, "Redo")
	}
	if filename != "" && !mainWidget.ed.Saved() {
		newParts = append(newParts, "Put")
	}
	newParts = append(newParts, "Exit")
	newParts = append(newParts, "|")

	new := strings.Join(newParts, " ")
	if old == new {
		return
	}

	if user == "" {
		user = " "
	}

	tagWidget.ed.Load([]byte(new + user))
}

var reallyQuit time.Time

func executeCmd(cmd string) {
	cmd = strings.TrimSpace(cmd)
	switch cmd {
	case "Put":
		save()
	case "Undo":
		mainWidget.ed.SendUndo()
	case "Redo":
		mainWidget.ed.SendRedo()
	case "Exit":
		if mainWidget.ed.Saved() || time.Since(reallyQuit) < 3*time.Second {
			win.Send(lifecycle.Event{To: lifecycle.StageDead})
		} else {
			tagWidget.ed.FindNext("Put")
			reallyQuit = time.Now()
		}
	}
}

func findInEditor(s string) {
	if s == "" {
		return
	}
	first, sz := utf8.DecodeRuneInString(s)
	switch first {
	case ':':
		mainWidget.ed.JumpTo(s[sz:])
	default:
		mainWidget.ed.FindNext(s)
	}
}<commit_msg>cmd/edit: refresh tag on Undo/Redo<commit_after>package main

import (
	"strings"
	"time"
	"unicode/utf8"

	"golang.org/x/mobile/event/lifecycle"
)

func updateTag() {
	old := string(tagWidget.ed.Contents())
	var user string
	if i := strings.Index(old, "|"); i > 0 {
		user = old[i+1:]
		old = old[:i+1]
	}

	var newParts []string
	if filename != "" {
		newParts = append(newParts, filename)
	}
	if mainWidget.ed.CanUndo() {
		newParts = append(newParts, "Undo")
	}
	if mainWidget.ed.CanRedo() {
		newParts = append(newParts, "Redo")
	}
	if filename != "" && !mainWidget.ed.Saved() {
		newParts = append(newParts, "Put")
	}
	newParts = append(newParts, "Exit")
	newParts = append(newParts, "|")

	new := strings.Join(newParts, " ")
	if old == new {
		return
	}

	if user == "" {
		user = " "
	}

	tagWidget.ed.Load([]byte(new + user))
}

var reallyQuit time.Time

func executeCmd(cmd string) {
	cmd = strings.TrimSpace(cmd)
	switch cmd {
	case "Put":
		save()
	case "Undo":
		mainWidget.ed.SendUndo()
		tagWidget.ed.Load([]byte{}) // force tag regeneration
	case "Redo":
		mainWidget.ed.SendRedo()
		tagWidget.ed.Load([]byte{})
	case "Exit":
		if mainWidget.ed.Saved() || time.Since(reallyQuit) < 3*time.Second {
			win.Send(lifecycle.Event{To: lifecycle.StageDead})
		} else {
			tagWidget.ed.FindNext("Put")
			reallyQuit = time.Now()
		}
	}
}

func findInEditor(s string) {
	if s == "" {
		return
	}
	first, sz := utf8.DecodeRuneInString(s)
	switch first {
	case ':':
		mainWidget.ed.JumpTo(s[sz:])
	default:
		mainWidget.ed.FindNext(s)
	}
}
{'fraction_non_alphanumeric': 0.17678631331767863, 'fraction_numerical': 0.004025494800402549, 'mean_word_length': 3.681318681318681, 'pattern_counts': {'":': 8, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2680878', 'n_tokens_mistral': 1275, 'n_tokens_neox': 1194, 'n_words': 227}