<commit_before>package edit

// ArgCompleter is an argument completer. Its Complete method is called with
// the head of the form, a list of preceding arguments and the (possibly empty)
// current argument. It should return a list of candidates for the current
// argument and errors.
type ArgCompleter interface {
	Complete(*ArgContext) ([]*candidate, error)
}

type ArgContext struct {
	head    string
	args    []string
	current string
	ed      *Editor
}

type FuncArgCompleter struct {
	impl func(*ArgContext) ([]*candidate, error)
}

func (fac FuncArgCompleter) Complete(ctx *ArgContext) ([]*candidate, error) {
	return fac.impl(ctx)
}

// CompleterTable provides $le:completer. It implements eval.IndexSetter.
type CompleterTable map[string]ArgCompleter

func (ct) Kind() string {
	return "map"
}

func (ct CompleterTable) Repr(indent int) string {
}

var DefaultArgCompleter = ""
var argCompleter map[string]ArgCompleter

func init() {
	argCompleter = map[string]ArgCompleter{
		DefaultArgCompleter: FuncArgCompleter{complFilename},
		"sudo":              FuncArgCompleter{complSudo},
	}
}

func completeArg(ctx *ArgContext) ([]*candidate, error) {
	Logger.Printf("completing argument: %q %q %q", ctx.head, ctx.args, ctx.current)
	compl, ok := argCompleter[ctx.head]
	if !ok {
		compl = argCompleter[DefaultArgCompleter]
	}
	return compl.Complete(ctx)
}

func complFilename(ctx *ArgContext) ([]*candidate, error) {
	return complFilenameInner(ctx.current, false)<commit_msg>Fix...<commit_after>package edit

// ArgCompleter is an argument completer. Its Complete method is called with
// the head of the form, a list of preceding arguments and the (possibly empty)
// current argument. It should return a list of candidates for the current
// argument and errors.
type ArgCompleter interface {
	Complete(*ArgContext) ([]*candidate, error)
}

type ArgContext struct {
	head    string
	args    []string
	current string
	ed      *Editor
}

type FuncArgCompleter struct {
	impl func(*ArgContext) ([]*candidate, error)
}

func (fac FuncArgCompleter) Complete(ctx *ArgContext) ([]*candidate, error) {
	return fac.impl(ctx)
}

// CompleterTable provides $le:completer. It implements eval.IndexSetter.
type CompleterTable map[string]ArgCompleter

func (CompleterTable) Kind() string {
	return "map"
}

func (ct CompleterTable) Repr(indent int) string {
	return ""
}

var DefaultArgCompleter = ""
var argCompleter map[string]ArgCompleter

func init() {
	argCompleter = map[string]ArgCompleter{
		DefaultArgCompleter: FuncArgCompleter{complFilename},
		"sudo":              FuncArgCompleter{complSudo},
	}
}

func completeArg(ctx *ArgContext) ([]*candidate, error) {
	Logger.Printf("completing argument: %q %q %q", ctx.head, ctx.args, ctx.current)
	compl, ok := argCompleter[ctx.head]
	if !ok {
		compl = argCompleter[DefaultArgCompleter]
	}
	return compl.Complete(ctx)
}

func complFilename(ctx *ArgContext) ([]*candidate, error) {
	return complFilenameInner(ctx.current, false)
{'fraction_non_alphanumeric': 0.11062542030934767, 'fraction_numerical': 0.0, 'mean_word_length': 4.891089108910891, 'pattern_counts': {'":': 2, '<': 3, '<?xml version=': 0, '>': 3, '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': '727205', 'n_tokens_mistral': 1003, 'n_tokens_neox': 965, 'n_words': 278}