瀏覽代碼

Fix an index out of bounds crash when using ansi256 color + bold (#125)

pancake 5 年之前
父節點
當前提交
3bbe5ef21c
共有 1 個文件被更改,包括 1 次插入4 次删除
  1. 1 4
      Sources/SwiftTerm/Apple/AppleTerminalView.swift

+ 1 - 4
Sources/SwiftTerm/Apple/AppleTerminalView.swift

@@ -171,17 +171,14 @@ extension TerminalView {
                 return nativeBackgroundColor.inverseColor()
             }
         case .ansi256(let ansi):
-            let midx = Int (ansi) + (isBold ? 8 : 0)
+            let midx = Int (ansi) + ((isBold && ansi < 248) ? 8: 0);
             if let c = colors [midx] {
                 return c
             }
-            
             let tcolor = Color.ansiColors [midx]
-            
             let newColor = TTColor.make (color: tcolor)
             colors [midx] = newColor
             return newColor
-            
         case .trueColor(let r, let g, let b):
             if let tc = trueColors [color] {
                 return tc