@@ -1038,7 +1038,19 @@ def show_bat_file_preview(self) -> bool:
10381038 Raises:
10391039 ExitNow: If this preview request is no longer active.
10401040 """
1041- bat_executable = config ["plugins" ]["bat" ]["executable" ]
1041+ from shutil import which
1042+
1043+ # luckily shutil.which handles absolute path for us, thanks
1044+ if not which (bat_executable := config ["plugins" ]["bat" ]["executable" ]):
1045+ config ["plugins" ]["bat" ]["enabled" ] = False
1046+ self .notify (
1047+ f"Bat executable not found: { bat_executable } .\n Disabling bat plugin." ,
1048+ title = "Plugins: Bat" ,
1049+ severity = "warning" ,
1050+ markup = False ,
1051+ )
1052+ return False
1053+
10421054 command = [
10431055 bat_executable ,
10441056 "--force-colorization" ,
@@ -1115,9 +1127,9 @@ def request_page(page: int) -> None:
11151127 return False
11161128
11171129 text_preview = self .call_from_thread (
1118- WindowedTextPreview ,
1119- source ,
1120- classes = "text_preview bat_preview" ,
1130+ lambda : WindowedTextPreview (
1131+ source , classes = "text_preview bat_preview"
1132+ ). data_bind ( type ( self . app ). ansi_color )
11211133 )
11221134 self .call_from_thread (self .mount , text_preview )
11231135 if should_cancel ():
@@ -1173,7 +1185,11 @@ def show_normal_file_preview(self) -> None:
11731185 max_file_size = config ["interface" ]["preview_text" ]["max_file_size" ]
11741186 signature = (str (max_file_size ), TEXT_PREVIEW_CACHE_VERSION )
11751187 content : str | None = load_from_cache (
1176- realpath , "windowed_text" , stat_result , signature , pass_as = str
1188+ realpath ,
1189+ "windowed_text" ,
1190+ stat_result ,
1191+ signature ,
1192+ pass_as = str ,
11771193 )
11781194 if content is None :
11791195 try :
@@ -1239,7 +1255,7 @@ def show_normal_file_preview(self) -> None:
12391255 language = language ,
12401256 line_numbers = config ["interface" ]["show_line_numbers" ],
12411257 classes = "text_preview" ,
1242- )
1258+ ). data_bind ( type ( self . app ). ansi_color )
12431259 )
12441260 )
12451261
0 commit comments