diff --git a/lib/modules/Tools.pmod/Hilfe.pmod b/lib/modules/Tools.pmod/Hilfe.pmod index fc18864360debe958db2f9cb4cf4969f05f5e6c8..b654ecfb70b629cccdc135c33639ee4942a3994a 100644 --- a/lib/modules/Tools.pmod/Hilfe.pmod +++ b/lib/modules/Tools.pmod/Hilfe.pmod @@ -1359,7 +1359,7 @@ protected class ParserState { //! Hilfe prompt when entering multiline expressions. int(0..1) finishedp() { if(sizeof(pstack)) return 0; - if(low_state->in_token) return 0; + if(low_state->remains) return 0; if(!sizeof(pipeline)) return 1; if(sizeof(pipeline)==1 && whitespace[pipeline[0][0]]) { pipeline = ({}); @@ -1605,24 +1605,28 @@ class Evaluator { void add_buffer(string s) { // Tokenize the input + int(0..1) finished = state->finishedp(); array(string) tokens = state->push_string(s+"\n"); array(string) words = s/" "; string command = words[0]; - // See if first token is a command and not a defined entity. - if(commands[command] && !has_index(constants, command) && - !has_index(variables, command) && !has_index(functions, command) && - (sizeof(words)==1 || words[1]!=";")) { - commands[command]->exec(this, s, words, tokens); - return; - } + if(finished) + { + // See if first token is a command and not a defined entity. + if(commands[command] && !has_index(constants, command) && + !has_index(variables, command) && !has_index(functions, command) && + (sizeof(words)==1 || words[1]!=";")) { + commands[command]->exec(this, s, words, tokens); + return; + } - // See if the command is executed in overridden mode. - if(sizeof(command) && command[0]=='.') { - command = command[1..]; - if(commands[command]) { - commands[command]->exec(this, s, words, tokens); - return; + // See if the command is executed in overridden mode. + if(sizeof(command) && command[0]=='.') { + command = command[1..]; + if(commands[command]) { + commands[command]->exec(this, s, words, tokens); + return; + } } } diff --git a/lib/modules/Tools.pmod/testsuite.in b/lib/modules/Tools.pmod/testsuite.in index 6a2cda0622d41269d3750effd87068abc7a76875..fa23d4b7755963a7a94e576798d8caee9eaf860e 100644 --- a/lib/modules/Tools.pmod/testsuite.in +++ b/lib/modules/Tools.pmod/testsuite.in @@ -202,6 +202,10 @@ test_hilfe("switch(a) { case 2: return 1; case 3: return 2; }", "Ok.\n") test_hilfe("ADT.struct struct = ADT.struct();", "") test_hilfe("ADT.struct struct = ADT.struct();", "") +test_hilfe( ({ "#\"", "set fisk\";" }), "\"\\n\"\n\"set fisk\""); +test_hilfe("set hedda", ""); +test_hilfe("f;", "0.0"); + test_do( add_constant("testhilfe") ) test_true([[ Tools.Hilfe.StdinHilfe ]])