mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-05-12 21:05:48 +02:00
bump gocui to be on 'simple' branch.
The master branch of gocui contains stuff I added for lazynpm which changes how the cursor is used. This will provide some benefits to lazygit as well but I don't yet have the motivation to make the required changed in lazygit to support it. So we're gonna be on the branch named 'simple' rather than master until I fix that up.
This commit is contained in:
parent
7ed8ee160d
commit
d5db02a899
13 changed files with 282 additions and 230 deletions
26
vendor/github.com/go-errors/errors/stackframe.go
generated
vendored
26
vendor/github.com/go-errors/errors/stackframe.go
generated
vendored
|
@ -1,9 +1,10 @@
|
|||
package errors
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"bytes"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"runtime"
|
||||
"strings"
|
||||
)
|
||||
|
@ -62,18 +63,29 @@ func (frame *StackFrame) String() string {
|
|||
|
||||
// SourceLine gets the line of code (from File and Line) of the original source if possible.
|
||||
func (frame *StackFrame) SourceLine() (string, error) {
|
||||
data, err := ioutil.ReadFile(frame.File)
|
||||
if frame.LineNumber <= 0 {
|
||||
return "???", nil
|
||||
}
|
||||
|
||||
file, err := os.Open(frame.File)
|
||||
if err != nil {
|
||||
return "", New(err)
|
||||
}
|
||||
defer file.Close()
|
||||
|
||||
lines := bytes.Split(data, []byte{'\n'})
|
||||
if frame.LineNumber <= 0 || frame.LineNumber >= len(lines) {
|
||||
return "???", nil
|
||||
scanner := bufio.NewScanner(file)
|
||||
currentLine := 1
|
||||
for scanner.Scan() {
|
||||
if currentLine == frame.LineNumber {
|
||||
return string(bytes.Trim(scanner.Bytes(), " \t")), nil
|
||||
}
|
||||
currentLine++
|
||||
}
|
||||
// -1 because line-numbers are 1 based, but our array is 0 based
|
||||
return string(bytes.Trim(lines[frame.LineNumber-1], " \t")), nil
|
||||
if err := scanner.Err(); err != nil {
|
||||
return "", New(err)
|
||||
}
|
||||
|
||||
return "???", nil
|
||||
}
|
||||
|
||||
func packageAndName(fn *runtime.Func) (string, string) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue