if h.Buf.Settings["smartpaste"].(bool) {
if h.Cursor.X > 0 && len(util.GetLeadingWhitespace([]byte(strings.TrimLeft(clip, "\r\n")))) == 0 {
leadingWS := util.GetLeadingWhitespace(h.Buf.LineBytes(h.Cursor.Y))
- clip = strings.Replace(clip, "\n", "\n"+string(leadingWS), -1)
+ clip = strings.ReplaceAll(clip, "\n", "\n"+string(leadingWS))
}
}
v := h.GetView()
if h.Buf.LinesNum()-(v.StartLine+v.Height) > v.Height/2 {
h.ScrollDown(v.Height / 2)
- } else {
- if h.Buf.LinesNum() >= v.Height {
- v.StartLine = h.Buf.LinesNum() - v.Height
- }
+ } else if h.Buf.LinesNum() >= v.Height {
+ v.StartLine = h.Buf.LinesNum() - v.Height
}
h.SetView(v)
return true
if startcursor.X != -1 && startcursor.Y != -1 {
b.StartCursor = startcursor
- } else {
- if b.Settings["savecursor"].(bool) || b.Settings["saveundo"].(bool) {
- err := b.Unserialize()
- if err != nil {
- screen.TermMessage(err)
- }
+ } else if b.Settings["savecursor"].(bool) || b.Settings["saveundo"].(bool) {
+ err := b.Unserialize()
+ if err != nil {
+ screen.TermMessage(err)
}
}
ws := util.GetLeadingWhitespace(l)
if len(ws) != 0 {
if toSpaces {
- ws = bytes.Replace(ws, []byte{'\t'}, bytes.Repeat([]byte{' '}, tabsize), -1)
+ ws = bytes.ReplaceAll(ws, []byte{'\t'}, bytes.Repeat([]byte{' '}, tabsize))
} else {
- ws = bytes.Replace(ws, bytes.Repeat([]byte{' '}, tabsize), []byte{'\t'}, -1)
+ ws = bytes.ReplaceAll(ws, bytes.Repeat([]byte{' '}, tabsize), []byte{'\t'})
}
}
// It returns an error if the asset could not be found or
// could not be loaded.
func Asset(name string) ([]byte, error) {
- cannonicalName := strings.Replace(name, "\\", "/", -1)
+ cannonicalName := strings.ReplaceAll(name, "\\", "/")
if f, ok := _bindata[cannonicalName]; ok {
a, err := f()
if err != nil {
// It returns an error if the asset could not be found or
// could not be loaded.
func AssetInfo(name string) (os.FileInfo, error) {
- cannonicalName := strings.Replace(name, "\\", "/", -1)
+ cannonicalName := strings.ReplaceAll(name, "\\", "/")
if f, ok := _bindata[cannonicalName]; ok {
a, err := f()
if err != nil {
// AssetDir("") will return []string{"data"}.
func AssetDir(name string) ([]string, error) {
node := _bintree
- if len(name) != 0 {
- cannonicalName := strings.Replace(name, "\\", "/", -1)
+ if name != "" {
+ cannonicalName := strings.ReplaceAll(name, "\\", "/")
pathList := strings.Split(cannonicalName, "/")
for _, p := range pathList {
node = node.Children[p]
}
func _filePath(dir, name string) string {
- cannonicalName := strings.Replace(name, "\\", "/", -1)
+ cannonicalName := strings.ReplaceAll(name, "\\", "/")
return filepath.Join(append([]string{dir}, strings.Split(cannonicalName, "/")...)...)
}
go func() {
// Run the process in the background and create the onExit callback
proc.Run()
- jobFunc := JobFunction{onExit, string(outbuf.Bytes()), userargs}
+ jobFunc := JobFunction{onExit, outbuf.String(), userargs}
Jobs <- jobFunc
}()
path = filepath.ToSlash(path)
if runtime.GOOS == "windows" {
// ':' is not valid in a path name on Windows but is ok on Unix
- path = strings.Replace(path, ":", "%", -1)
+ path = strings.ReplaceAll(path, ":", "%")
}
- return strings.Replace(path, "/", "%", -1)
+ return strings.ReplaceAll(path, "/", "%")
}
// GetLeadingWhitespace returns the leading whitespace of the given byte array
}
func ParseSpecial(s string) string {
- return strings.Replace(s, "\\t", "\t", -1)
+ return strings.ReplaceAll(s, "\\t", "\t")
}
// String converts a byte array to a string (for lua plugins)