<commit_before>package readline

import (
	"errors"
	"fmt"
	"strings"
)

// TODO: print with a pretty format
func printCandidates(inst *Instance, cp Completer, candidates []string) {
	args := strings.Fields(string(inst.line))
	prefix := args[len(args)-1]
	inst.Print("\n")
	for _, n := range candidates {
		inst.Printf("%s\t", cp.modifyCandidate(prefix, n))
	}<commit_msg>fix: out of slice index when line is empty<commit_after>package readline

import (
	"errors"
	"fmt"
	"strings"
)

// TODO: print with a pretty format
func printCandidates(inst *Instance, cp Completer, candidates []string) {
	var prefix string
	args := strings.Fields(string(inst.line))
	if len(args) != 0 {
		prefix = args[len(args)-1]
	}
	inst.Print("\n")
	for _, n := range candidates {
		inst.Printf("%s\t", cp.modifyCandidate(prefix, n))
	}
{'fraction_non_alphanumeric': 0.15441176470588236, 'fraction_numerical': 0.003676470588235294, 'mean_word_length': 4.595890410958904, 'pattern_counts': {'":': 0, '<': 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': '4355804', 'n_tokens_mistral': 292, 'n_tokens_neox': 286, 'n_words': 76}