zqqw / pakku

Pacman wrapper with AUR support
GNU General Public License v3.0
39 stars 3 forks source link

Some searches with pakku -Ss fail #1

Closed zqqw closed 4 years ago

zqqw commented 4 years ago

Compiling pakku for debug not release:

$ pakku -Ss linux
...
aur/linux-a11y-sound-theme r19.730e525-1 [0 / 0.000000]
    Sound theme for the linux accessibility organization
aur/linux-aarch64-raspberrypi 4.19.76.r791998.gf1da5f42022d-2 [2 / 0.000080]
/src/pakku/src/main.nim(263) main
t/src/pakku/src/main.nim(254) run
/pakku/src/main.nim(92) handleSync
/pakku/src/feature/syncsearch.nim(53) handleSyncSearch
/pakku/src/format.nim(152) printPackageSearch
/pakku/src/format.nim(86) splitLines
/usr/lib/nim/pure/unicode.nim(322) runeOffset
/usr/lib/nim/pure/unicode.nim(62) runeLenAt
/usr/lib/nim/system/fatal.nim(49) sysFatal
Error: unhandled exception: index out of bounds, the container is empty [IndexError]

With this build, many searches work but some fail, like "linux" or "steam". No problems updating, installing or removing packages so far.

zqqw commented 4 years ago

This seems to fix it, although it isn't well tested yet so I'll push it later when I have had a chance to look at it more, but sometimes "text" is empty as there is no description and runeOffset doesn't like this.

--- a/src/format.nim
+++ b/src/format.nim
@@ -83,7 +83,9 @@ proc splitLines(text: string, lineSize: int, lines: seq[string] = @[]): seq[stri
   if not addBreaks:
     lines & text
   else:
-    let offset = text.runeOffset(lineSize)
+    var offset : int = -1
+    if text.len() != 0:
+      offset = text.runeOffset(lineSize)
     if offset < 0:
       lines & text
     else:
@@ -309,7 +311,7 @@ proc printProgressFull*(bar: bool, title: string): ((string, float) -> void, ()
     var lastProgress = 0f
     var averageSpeed = -1f
zqqw commented 4 years ago

Closed by Fix -Ss index out of bounds, the container is empty [IndexError] (runeOffset: empty description field) 36e59748983034d5d39293e5d2415e92c14e2a22