fix: reviewers not correctly shown on dashboard edit screen
This commit is contained in:
@@ -25,6 +25,11 @@ type textFind struct {
|
||||
valid bool
|
||||
}
|
||||
|
||||
type editorProtectedStyle struct {
|
||||
start, end int
|
||||
color string
|
||||
}
|
||||
|
||||
// textEditor owns buffer and motion state independently of any particular
|
||||
// screen. Inputs can opt into modal behavior without duplicating cursor logic.
|
||||
type textEditor struct {
|
||||
@@ -41,6 +46,8 @@ type textEditor struct {
|
||||
err error
|
||||
hardwareCursor bool
|
||||
highlightMarkdown bool
|
||||
protectedPrefix int
|
||||
protectedStyles []editorProtectedStyle
|
||||
keys KeyBindings
|
||||
}
|
||||
|
||||
@@ -838,7 +845,7 @@ func renderTextEditor(editor textEditor, width int, active bool) []editorRendere
|
||||
rendered := renderEditorVisualLine(
|
||||
line, cursor, editor.Mode, selectionStart, selectionEnd,
|
||||
active && hasSelection, active && onVisualLine, editor.hardwareCursor,
|
||||
markdownStyles, width,
|
||||
markdownStyles, width, editor.protectedPrefix, editor.protectedStyles,
|
||||
)
|
||||
if active && onVisualLine {
|
||||
rendered = pad(rendered, width)
|
||||
@@ -908,7 +915,8 @@ func renderEditorVisualLine(
|
||||
selectionStart, selectionEnd int,
|
||||
hasSelection, showCursor, hardwareCursor bool,
|
||||
markdownStyles []editorMarkdownStyle,
|
||||
width int,
|
||||
width, protectedPrefix int,
|
||||
protectedStyles []editorProtectedStyle,
|
||||
) string {
|
||||
const (
|
||||
reverseStart = "\x1b[7m"
|
||||
@@ -919,9 +927,32 @@ func renderEditorVisualLine(
|
||||
runes := []rune(line.text)
|
||||
var rendered strings.Builder
|
||||
selected := false
|
||||
protectedColor := ""
|
||||
markdownStyle := editorMarkdownPlain
|
||||
for offset, value := range runes {
|
||||
position := line.start + offset
|
||||
nextProtectedColor := ""
|
||||
if position < protectedPrefix {
|
||||
nextProtectedColor = editorMarkdownTheme.Dim
|
||||
}
|
||||
for _, style := range protectedStyles {
|
||||
if position >= style.start && position < style.end {
|
||||
nextProtectedColor = style.color
|
||||
break
|
||||
}
|
||||
}
|
||||
if nextProtectedColor != protectedColor {
|
||||
if colorEnabled && nextProtectedColor != "" {
|
||||
rendered.WriteString(foregroundSequence(nextProtectedColor))
|
||||
} else if colorEnabled && protectedColor != "" {
|
||||
if showCursor {
|
||||
rendered.WriteString(foregroundSequence(editorMarkdownTheme.EditorForeground))
|
||||
} else {
|
||||
rendered.WriteString("\x1b[39m")
|
||||
}
|
||||
}
|
||||
protectedColor = nextProtectedColor
|
||||
}
|
||||
nextMarkdownStyle := editorMarkdownPlain
|
||||
if position < len(markdownStyles) {
|
||||
nextMarkdownStyle = markdownStyles[position]
|
||||
@@ -979,6 +1010,13 @@ func renderEditorVisualLine(
|
||||
if markdownStyle != editorMarkdownPlain {
|
||||
rendered.WriteString(editorMarkdownStyleEnd(showCursor))
|
||||
}
|
||||
if protectedColor != "" && colorEnabled {
|
||||
if showCursor {
|
||||
rendered.WriteString(foregroundSequence(editorMarkdownTheme.EditorForeground))
|
||||
} else {
|
||||
rendered.WriteString("\x1b[39m")
|
||||
}
|
||||
}
|
||||
if showCursor && cursor == line.end {
|
||||
switch mode {
|
||||
case textEditorInsert:
|
||||
|
||||
Reference in New Issue
Block a user