From 7b3ce0f39d10354372f6d21e3f7e0440ec368093 Mon Sep 17 00:00:00 2001 From: ivarne Date: Thu, 26 Sep 2013 14:31:17 +0200 Subject: [PATCH 1/4] Added support for method(\t syntax for operators --- ui/repl-readline.c | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/ui/repl-readline.c b/ui/repl-readline.c index f7ba1495a6243..243de787e6d07 100644 --- a/ui/repl-readline.c +++ b/ui/repl-readline.c @@ -250,12 +250,21 @@ int complete_method_table() { // extract the token preceding the ( int tokenstart = rl_point-2; - while (tokenstart>=0 && (jl_word_char(rl_line_buffer[tokenstart]) || - rl_line_buffer[tokenstart] == '!')) { - tokenstart--; + // check for special operators + if (strchr("\\><=|&+-*/%^~!", rl_line_buffer[tokenstart])){ + while (tokenstart>0 && strchr("<>=!", rl_line_buffer[tokenstart-1])){ + tokenstart--; + } + } + else{ + // check for functions that might contain ! but not start with ! + while (tokenstart>=0 && (jl_word_char(rl_line_buffer[tokenstart]) || + rl_line_buffer[tokenstart] == '!')) { + tokenstart--; + } + tokenstart++; + tokenstart += rl_line_buffer[tokenstart] == '!'; } - tokenstart++; - tokenstart += rl_line_buffer[tokenstart] == '!'; jl_value_t* result = call_jl_function_with_string("repl_methods", &rl_line_buffer[tokenstart], From 0a09f5580f0f845f4392fd33f7248e1f1f6b2311 Mon Sep 17 00:00:00 2001 From: ivarne Date: Thu, 26 Sep 2013 18:46:41 +0200 Subject: [PATCH 2/4] Fixed completion behaviour of functions that end in ! --- ui/repl-readline.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/ui/repl-readline.c b/ui/repl-readline.c index 243de787e6d07..ee2a3d17f3497 100644 --- a/ui/repl-readline.c +++ b/ui/repl-readline.c @@ -251,7 +251,7 @@ int complete_method_table() { int tokenstart = rl_point-2; // check for special operators - if (strchr("\\><=|&+-*/%^~!", rl_line_buffer[tokenstart])){ + if (strchr("\\><=|&+-*/%^~", rl_line_buffer[tokenstart])){ while (tokenstart>0 && strchr("<>=!", rl_line_buffer[tokenstart-1])){ tokenstart--; } @@ -263,7 +263,10 @@ int complete_method_table() { tokenstart--; } tokenstart++; - tokenstart += rl_line_buffer[tokenstart] == '!'; + // ! can't be the first character of a function, unless is not the only + if (tokenstart != rl_point-2 && rl_line_buffer[tokenstart] == '!'){ + tokenstart ++; + } } jl_value_t* result = call_jl_function_with_string("repl_methods", From f4d1f5ed948270ad7f8517a1dfdf5a68c61c204d Mon Sep 17 00:00:00 2001 From: ivarne Date: Thu, 26 Sep 2013 19:31:03 +0200 Subject: [PATCH 3/4] fix typo --- ui/repl-readline.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ui/repl-readline.c b/ui/repl-readline.c index ee2a3d17f3497..2d53253a3c6ee 100644 --- a/ui/repl-readline.c +++ b/ui/repl-readline.c @@ -263,7 +263,7 @@ int complete_method_table() { tokenstart--; } tokenstart++; - // ! can't be the first character of a function, unless is not the only + // ! can't be the first character of a function, unless is's the only if (tokenstart != rl_point-2 && rl_line_buffer[tokenstart] == '!'){ tokenstart ++; } From 3315f19fb419aab076ece4aca00f8138d2b6d15e Mon Sep 17 00:00:00 2001 From: Ivar Nesje Date: Thu, 26 Sep 2013 23:00:54 +0200 Subject: [PATCH 4/4] sorry for another typo in the same comment. --- ui/repl-readline.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ui/repl-readline.c b/ui/repl-readline.c index 2d53253a3c6ee..7af8768399291 100644 --- a/ui/repl-readline.c +++ b/ui/repl-readline.c @@ -263,7 +263,7 @@ int complete_method_table() { tokenstart--; } tokenstart++; - // ! can't be the first character of a function, unless is's the only + // ! can't be the first character of a function, unless it's the only character if (tokenstart != rl_point-2 && rl_line_buffer[tokenstart] == '!'){ tokenstart ++; }