From deccc8ea1689bf596b0ff6de2b6ae092cf312599 Mon Sep 17 00:00:00 2001 From: Jeremie Dimino Date: Tue, 24 Jun 2014 14:25:49 +0100 Subject: [PATCH] Don't stylise uge strings Fix #73 --- src/lib/uTop_main.ml | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/src/lib/uTop_main.ml b/src/lib/uTop_main.ml index c3820cd..89598a5 100644 --- a/src/lib/uTop_main.ml +++ b/src/lib/uTop_main.ml @@ -231,16 +231,20 @@ let fix_string str = end let render_out_phrase term string = - let string = fix_string string in - let styled = LTerm_text.of_string string in - let stylise loc token_style = - for i = loc.idx1 to loc.idx2 - 1 do - let ch, style = styled.(i) in - styled.(i) <- (ch, LTerm_style.merge token_style style) - done - in - UTop_styles.stylise stylise (UTop_lexer.lex_string (UTop.get_syntax ()) string); - LTerm.fprints term styled + if String.length string >= 100 * 1024 then + LTerm.fprint term string + else begin + let string = fix_string string in + let styled = LTerm_text.of_string string in + let stylise loc token_style = + for i = loc.idx1 to loc.idx2 - 1 do + let ch, style = styled.(i) in + styled.(i) <- (ch, LTerm_style.merge token_style style) + done + in + UTop_styles.stylise stylise (UTop_lexer.lex_string (UTop.get_syntax ()) string); + LTerm.fprints term styled + end let orig_print_out_signature = !Toploop.print_out_signature let orig_print_out_phrase = !Toploop.print_out_phrase