<commit_before>package peco

import (
	"fmt"
	"regexp"
	"sort"
	"strings"
)

// Match defines the interface for matches. Note that to make drawing easier,
// we have a DidMatch and NoMatch types instead of using []Match and []string.
type Match interface {
	Buffer() string // Raw buffer, may contain null
	Line() string // Line to be displayed
	Output() string // Output string to be displayed after peco is done
	Indices() [][]int
}

type MatchString struct {
	buf string
	sepLoc int
}

func NewMatchString(v string, enableSep bool) *MatchString {
	m := &MatchString{
		v,
		-1,
	}
	if !enableSep {
		return m
	}

	// XXX This may be silly, but we're avoiding using strings.IndexByte()
	// here because it doesn't exist on go1.1. Let's remove support for
	// 1.1 when 1.4 comes out (or something)
	for i := 0; i < len(m.buf); i++ {
		if m.buf[i] == '\000' {
			m.sepLoc = i
		}
	}
	return m
}

func (m MatchString) Buffer() string {
	return m.buf
}

func (m MatchString) Line() string {
	if i := m.sepLoc; i > -1 {
		return m.buf[:i]
	}
	return m.buf
}

func (m MatchString) Output() string {
	if i := m.sepLoc; i > -1 {
		return m.buf[i:]
	}
	return m.buf
}

// NoMatch is actually an alias to a regular string. It implements the
// Match interface, but just returns the underlying string with no matches
type NoMatch struct {
	*MatchString
}

func NewNoMatch(v string, enableSep bool) *NoMatch {<commit_msg>Fix off-by-one<commit_after>package peco

import (
	"fmt"
	"regexp"
	"sort"
	"strings"
)

// Match defines the interface for matches. Note that to make drawing easier,
// we have a DidMatch and NoMatch types instead of using []Match and []string.
type Match interface {
	Buffer() string // Raw buffer, may contain null
	Line() string // Line to be displayed
	Output() string // Output string to be displayed after peco is done
	Indices() [][]int
}

type MatchString struct {
	buf string
	sepLoc int
}

func NewMatchString(v string, enableSep bool) *MatchString {
	m := &MatchString{
		v,
		-1,
	}
	if !enableSep {
		return m
	}

	// XXX This may be silly, but we're avoiding using strings.IndexByte()
	// here because it doesn't exist on go1.1. Let's remove support for
	// 1.1 when 1.4 comes out (or something)
	for i := 0; i < len(m.buf); i++ {
		if m.buf[i] == '\000' {
			m.sepLoc = i
		}
	}
	return m
}

func (m MatchString) Buffer() string {
	return m.buf
}

func (m MatchString) Line() string {
	if i := m.sepLoc; i > -1 {
		return m.buf[:i]
	}
	return m.buf
}

func (m MatchString) Output() string {
	if i := m.sepLoc; i > -1 {
		return m.buf[i+1:]
	}
	return m.buf
}

// NoMatch is actually an alias to a regular string. It implements the
// Match interface, but just returns the underlying string with no matches
type NoMatch struct {
	*MatchString
}

func NewNoMatch(v string, enableSep bool) *NoMatch {
{'fraction_non_alphanumeric': 0.11858407079646018, 'fraction_numerical': 0.009557522123893806, 'mean_word_length': 3.205357142857143, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, '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': '3039672', 'n_tokens_mistral': 1006, 'n_tokens_neox': 969, 'n_words': 383}