From fc5cdbe1c647a4ddcc5d4cdfe62e683d62dea82e Mon Sep 17 00:00:00 2001 From: Max Horn Date: Tue, 6 Dec 2022 22:20:57 +0100 Subject: [PATCH] Fix an unexpected error during tab completion --- dev/gaptest.expect | 17 +++++++++++++++++ lib/cmdledit.g | 4 ++-- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/dev/gaptest.expect b/dev/gaptest.expect index 9012a4c2a5..288135e978 100644 --- a/dev/gaptest.expect +++ b/dev/gaptest.expect @@ -50,6 +50,23 @@ expect "gap> " send -- "g!.S\t" expect "ize" send -- ";;\r" + +# issue 5241 +expect "gap> " +# this used to trigger an error +send -- "g.x.\t" +# ctrl-u to clear the input given so far +send -- "\025" +# just start a new line to verify we are not in a break loop +send -- "\r" +expect "gap> " +# this also used to trigger an error +send -- "g!.x.\t" +# ctrl-u to clear the input given so far +send -- "\025" +# just start a new line to verify we are not in a break loop +send -- "\r" expect "gap> " exit + diff --git a/lib/cmdledit.g b/lib/cmdledit.g index c82393ad54..d847ec2d46 100644 --- a/lib/cmdledit.g +++ b/lib/cmdledit.g @@ -969,9 +969,9 @@ GAPInfo.CommandLineEditFunctions.Functions.Completion := function(l) if Length(cmps) > 0 and cmps[1] in idbnd then r := ValueGlobal(cmps[1]); for j in [2..Length(cmps)] do - if not hasbang[j-1] and IsBound(r.(cmps[j])) then + if not hasbang[j-1] and IsRecord(r) and IsBound(r.(cmps[j])) then r := r.(cmps[j]); - elif hasbang[j-1] and IsBound(r!.(cmps[j])) then + elif hasbang[j-1] and (IsRecord(r) or IsComponentObjectRep(r)) and IsBound(r!.(cmps[j])) then r := r!.(cmps[j]); else r := fail;