1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-07-17 01:42:45 +02:00

fix delta

This commit is contained in:
Jesse Duffield
2020-10-11 09:49:07 +11:00
parent 582fd24d78
commit b8ad1883f5
5 changed files with 71 additions and 8 deletions

View File

@ -16,6 +16,19 @@ type escapeInterpreter struct {
csiParam []string
curFgColor, curBgColor Attribute
mode OutputMode
instruction instruction
}
const (
NONE = 1 << iota
ERASE_IN_LINE
)
type instruction struct {
kind int
param1 int
param2 int
toWrite []rune
}
type escapeState int
@ -57,10 +70,11 @@ func (ei *escapeInterpreter) runes() []rune {
// terminal escape sequences.
func newEscapeInterpreter(mode OutputMode) *escapeInterpreter {
ei := &escapeInterpreter{
state: stateNone,
curFgColor: ColorDefault,
curBgColor: ColorDefault,
mode: mode,
state: stateNone,
curFgColor: ColorDefault,
curBgColor: ColorDefault,
mode: mode,
instruction: instruction{kind: NONE},
}
return ei
}
@ -73,6 +87,10 @@ func (ei *escapeInterpreter) reset() {
ei.csiParam = nil
}
func (ei *escapeInterpreter) instructionRead() {
ei.instruction.kind = NONE
}
// parseOne parses a rune. If isEscape is true, it means that the rune is part
// of an escape sequence, and as such should not be printed verbatim. Otherwise,
// it's not an escape sequence.
@ -131,6 +149,17 @@ func (ei *escapeInterpreter) parseOne(ch rune) (isEscape bool, err error) {
return false, errCSIParseError
}
ei.state = stateNone
ei.csiParam = nil
return true, nil
case ch == 'K':
p, err := strconv.Atoi(ei.csiParam[0])
if err != nil {
return false, errCSIParseError
}
ei.instruction.kind = ERASE_IN_LINE
ei.instruction.param1 = p
ei.state = stateNone
ei.csiParam = nil
return true, nil