mirror of
https://github.com/go-sylixos/elvish.git
synced 2024-12-01 00:33:05 +08:00
pkg/eval: Use eval.ChopLineEnding everywhere for removing line ending.
This commit is contained in:
parent
721a0026df
commit
eb37f92300
|
@ -473,7 +473,7 @@ func adaptArgGeneratorMap(ev *eval.Evaler, m vals.Map) complete.ArgGenerator {
|
|||
for {
|
||||
line, err := buffered.ReadString('\n')
|
||||
if line != "" {
|
||||
collect(complete.PlainItem(strings.TrimRight(line, "\r\n")))
|
||||
collect(complete.PlainItem(eval.ChopLineEnding(line)))
|
||||
}
|
||||
if err != nil {
|
||||
break
|
||||
|
|
|
@ -4,7 +4,6 @@ import (
|
|||
"bufio"
|
||||
"io"
|
||||
"os"
|
||||
"strings"
|
||||
"sync"
|
||||
|
||||
"github.com/elves/elvish/pkg/cli"
|
||||
|
@ -72,7 +71,7 @@ func instantStart(app cli.App, ev *eval.Evaler, binding cli.Handler) {
|
|||
}
|
||||
break
|
||||
}
|
||||
addLine(strings.TrimRight(line, "\r\n"))
|
||||
addLine(eval.ChopLineEnding(line))
|
||||
}
|
||||
}
|
||||
err = fm.PipeOutput(
|
||||
|
|
|
@ -55,7 +55,7 @@ func listingStartCustom(ed *Editor, fm *eval.Frame, opts customListingOpts, item
|
|||
for {
|
||||
line, err := buffered.ReadString('\n')
|
||||
if line != "" {
|
||||
s := strings.TrimRight(line, "\r\n")
|
||||
s := eval.ChopLineEnding(line)
|
||||
collect(listing.Item{ToAccept: s, ToShow: ui.T(s)})
|
||||
}
|
||||
if err != nil {
|
||||
|
|
|
@ -361,7 +361,7 @@ func captureOutput(fm *Frame, f func(*Frame) error) ([]interface{}, error) {
|
|||
for {
|
||||
line, err := buffered.ReadString('\n')
|
||||
if line != "" {
|
||||
v := strings.TrimRight(line, "\r\n")
|
||||
v := ChopLineEnding(line)
|
||||
m.Lock()
|
||||
vs = append(vs, v)
|
||||
m.Unlock()
|
||||
|
|
|
@ -5,7 +5,6 @@ import (
|
|||
"fmt"
|
||||
"io"
|
||||
"os"
|
||||
"strings"
|
||||
"sync"
|
||||
|
||||
"github.com/elves/elvish/pkg/diag"
|
||||
|
@ -108,7 +107,7 @@ func linesToChan(r io.Reader, ch chan<- interface{}) {
|
|||
for {
|
||||
line, err := filein.ReadString('\n')
|
||||
if line != "" {
|
||||
ch <- strings.TrimRight(line, "\r\n")
|
||||
ch <- ChopLineEnding(line)
|
||||
}
|
||||
if err != nil {
|
||||
if err != io.EOF {
|
||||
|
|
|
@ -5,7 +5,8 @@ import (
|
|||
"fmt"
|
||||
"io"
|
||||
"os"
|
||||
"strings"
|
||||
|
||||
"github.com/elves/elvish/pkg/eval"
|
||||
)
|
||||
|
||||
type editor interface {
|
||||
|
@ -28,7 +29,5 @@ func (ed *minEditor) ReadCode() (string, error) {
|
|||
}
|
||||
fmt.Fprintf(ed.out, "%s> ", wd)
|
||||
line, err := ed.in.ReadString('\n')
|
||||
// Chop off the trailing \r on Windows.
|
||||
line = strings.TrimRight(line, "\r\n")
|
||||
return line, err
|
||||
return eval.ChopLineEnding(line), err
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user