<commit_before>// package backend provides the backend implementations of the goed
// editor text buffers.
package backend

import (
	"os/exec"
	"path"
	"strconv"
	"strings"

	"github.com/tcolar/goed/core"
)

func BufferFile(id int64) string {
	return path.Join(core.Home, "buffers", strconv.FormatInt(id, 10))
}

// NewMemBackendCmd creates a Comand runner backed by an In-memory based backend
// if title == nil then will show the command name
func NewMemBackendCmd(args []string, dir string, viewId int64, title *string) (*BackendCmd, error) {
	b, err := NewMemBackend("", viewId)
	if err != nil {
		return nil, err
	}
	c, err := newBackendCmd(args, dir, viewId, title)
	if err != nil {
		return nil, err
	}
	c.Backend = b
	c.Starter = &MemCmdStarter{}
	go c.Start(viewId)
	return c, nil
}

func newBackendCmd(args []string, dir string, viewId int64, title *string) (*BackendCmd, error) {
	c := &BackendCmd{
		dir:    dir,
		runner: exec.Command(args[0], args[1:]...),
		title:  title,
	}
	c.runner.Dir = dir
	if c.title == nil {
		title := strings.Join(c.runner.Args, " ")
		c.title = &title
	}
	return c, nil
}
<commit_msg>For some commands scrool to top after (ie: dir listing)<commit_after>// package backend provides the backend implementations of the goed
// editor text buffers.
package backend

import (
	"os/exec"
	"path"
	"strconv"
	"strings"

	"github.com/tcolar/goed/core"
)

func BufferFile(id int64) string {
	return path.Join(core.Home, "buffers", strconv.FormatInt(id, 10))
}

// NewMemBackendCmd creates a Comand runner backed by an In-memory based backend
// if title == nil then will show the command name
func NewMemBackendCmd(args []string, dir string, viewId int64, title *string, scrollTop bool) (*BackendCmd, error) {
	b, err := NewMemBackend("", viewId)
	if err != nil {
		return nil, err
	}
	c, err := newBackendCmd(args, dir, viewId, title)
	if err != nil {
		return nil, err
	}
	c.scrollTop = scrollTop
	c.Backend = b
	c.Backend.Wipe()

	c.Starter = &MemCmdStarter{}
	go c.Start(viewId)
	return c, nil
}

func newBackendCmd(args []string, dir string, viewId int64, title *string) (*BackendCmd, error) {
	c := &BackendCmd{
		dir:    dir,
		runner: exec.Command(args[0], args[1:]...),
		title:  title,
	}
	c.runner.Dir = dir
	if c.title == nil {
		title := strings.Join(c.runner.Args, " ")
		c.title = &title
	}
	return c, nil
}

{'fraction_non_alphanumeric': 0.13825275657336725, 'fraction_numerical': 0.008481764206955046, 'mean_word_length': 3.834016393442623, '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': '2835682', 'n_tokens_mistral': 876, 'n_tokens_neox': 862, 'n_words': 262}