summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--degesch.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/degesch.c b/degesch.c
index 436e9eb..f4deab3 100644
--- a/degesch.c
+++ b/degesch.c
@@ -5056,6 +5056,16 @@ make_prompt (struct app_context *ctx, struct str *output)
}
static void
+input_maybe_set_prompt (struct input *self, char *new_prompt)
+{
+ // Redisplay can be an expensive operation
+ if (self->prompt && !strcmp (new_prompt, self->prompt))
+ free (new_prompt);
+ else
+ input_set_prompt (self, new_prompt);
+}
+
+static void
refresh_prompt (struct app_context *ctx)
{
bool have_attributes = !!get_attribute_printer (stdout);
@@ -5070,7 +5080,7 @@ refresh_prompt (struct app_context *ctx)
if (have_attributes)
{
// XXX: to be completely correct, we should use tputs, but we cannot
- input_set_prompt (&ctx->input, xstrdup_printf ("%c%s%c%s%c%s%c",
+ input_maybe_set_prompt (&ctx->input, xstrdup_printf ("%c%s%c%s%c%s%c",
INPUT_START_IGNORE, ctx->attrs[ATTR_PROMPT],
INPUT_END_IGNORE,
localized,
@@ -5079,7 +5089,7 @@ refresh_prompt (struct app_context *ctx)
free (localized);
}
else
- input_set_prompt (&ctx->input, localized);
+ input_maybe_set_prompt (&ctx->input, localized);
}
// --- Helpers -----------------------------------------------------------------