mirror of
https://github.com/taigrr/wtf
synced 2025-01-18 04:03:14 -08:00
Merge branch 'jeangovil-todo-fix'
This commit is contained in:
commit
1d23d5369f
@ -15,15 +15,14 @@ func (widget *Widget) display() {
|
||||
|
||||
str := ""
|
||||
checked := []*Item{}
|
||||
uncheckedLen := 0
|
||||
var selected *Item
|
||||
var selectedItem *Item
|
||||
var newList List
|
||||
for idx, item := range widget.list.Items {
|
||||
foreColor, backColor := "white", "black"
|
||||
|
||||
// save the selected one
|
||||
if idx == widget.list.selected {
|
||||
selected = item
|
||||
selectedItem = item
|
||||
}
|
||||
|
||||
if item.Checked {
|
||||
@ -31,11 +30,7 @@ func (widget *Widget) display() {
|
||||
continue
|
||||
}
|
||||
|
||||
uncheckedLen++
|
||||
|
||||
if widget.View.HasFocus() && item == selected {
|
||||
// set selected item index
|
||||
newList.selected = idx
|
||||
if widget.View.HasFocus() && item == selectedItem {
|
||||
foreColor = Config.UString("wtf.mods.todo.colors.highlight.fore", "black")
|
||||
backColor = Config.UString("wtf.mods.todo.colors.highlight.back", "white")
|
||||
}
|
||||
@ -52,11 +47,10 @@ func (widget *Widget) display() {
|
||||
|
||||
newList.Items = append(newList.Items, item)
|
||||
}
|
||||
for idx, item := range checked {
|
||||
for _, item := range checked {
|
||||
foreColor, backColor := Config.UString("wtf.mods.todo.colors.checked", "white"), "black"
|
||||
|
||||
if widget.View.HasFocus() && item == selected {
|
||||
newList.selected = idx + uncheckedLen
|
||||
if widget.View.HasFocus() && item == selectedItem {
|
||||
foreColor = Config.UString("wtf.mods.todo.colors.highlight.fore", "black")
|
||||
backColor = Config.UString("wtf.mods.todo.colors.highlight.back", "white")
|
||||
}
|
||||
@ -73,6 +67,13 @@ func (widget *Widget) display() {
|
||||
newList.Items = append(newList.Items, item)
|
||||
}
|
||||
|
||||
// update selected index with new index of selected item
|
||||
for idx, item := range newList.Items {
|
||||
if item == selectedItem {
|
||||
newList.selected = idx
|
||||
}
|
||||
}
|
||||
|
||||
// update list with new Items and selected item index
|
||||
widget.list = &newList
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user