mirror of
https://github.com/anotherhadi/spilltea.git
synced 2026-05-21 02:02:34 +02:00
fix: log silent errors, harden proxy auth, optimize db and render pipeline
Signed-off-by: Hadi <112569860+anotherhadi@users.noreply.github.com>
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package util
|
||||
|
||||
import (
|
||||
"log"
|
||||
"os"
|
||||
"os/exec"
|
||||
|
||||
@@ -27,7 +28,9 @@ func OpenExternalEditor(content string) tea.Cmd {
|
||||
return nil
|
||||
}
|
||||
tmpPath := f.Name()
|
||||
_, _ = f.WriteString(content)
|
||||
if _, err := f.WriteString(content); err != nil {
|
||||
log.Printf("editor: writing temp file: %v", err)
|
||||
}
|
||||
f.Close()
|
||||
return tea.ExecProcess(exec.Command(editor, tmpPath), func(err error) tea.Msg {
|
||||
defer os.Remove(tmpPath)
|
||||
|
||||
@@ -3,6 +3,7 @@ package util
|
||||
import (
|
||||
"strings"
|
||||
|
||||
"charm.land/bubbles/v2/paginator"
|
||||
"charm.land/lipgloss/v2"
|
||||
)
|
||||
|
||||
@@ -28,6 +29,18 @@ func CenterLines(lines ...string) string {
|
||||
return strings.Join(centered, "\n")
|
||||
}
|
||||
|
||||
// PageBounds returns clamped start/end indices for rendering a paginated list.
|
||||
func PageBounds(p paginator.Model, total int) (start, end int) {
|
||||
start, end = p.GetSliceBounds(total)
|
||||
if start < 0 {
|
||||
start = 0
|
||||
}
|
||||
if end < start {
|
||||
end = start
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// InferScheme returns "http" for port 80, "https" otherwise.
|
||||
func InferScheme(host string) string {
|
||||
if strings.HasSuffix(host, ":80") {
|
||||
|
||||
Reference in New Issue
Block a user