# HG changeset patch # User Torsten # Date 1407778088 -7200 # Node ID bf7c5d96d1ff1b2d70d0a3320e82a08f8954e298 # Parent e87e65bc71ae08017e2886d750a60a2c24c90898 improved regexp for file name suggestion when saving a new editor file * file-editor-tab.cc (get_function_name): improved regexp used for finding the function name when saving a new function file in the editor diff -r e87e65bc71ae -r bf7c5d96d1ff libgui/src/m-editor/file-editor-tab.cc --- a/libgui/src/m-editor/file-editor-tab.cc Mon Aug 11 17:24:37 2014 +0200 +++ b/libgui/src/m-editor/file-editor-tab.cc Mon Aug 11 19:28:08 2014 +0200 @@ -1867,20 +1867,23 @@ QString file_editor_tab::get_function_name () { - QRegExp rxfun1 ("^([\t ]*)function([^=]+)=([^\\(]+)\\(([^\\)]*)\\)"); - QRegExp rxfun2 ("^([\t ]*)function([^\\(]+)\\(([^\\)]*)\\)"); - QRegExp rxfun3 ("^([\t ]*)function([\t ]*)([^\t ]+)"); + QRegExp rxfun1 ("^[\t ]*function[^=]+=([^\\(]+)\\([^\\)]*\\)[\t ]*$"); + QRegExp rxfun2 ("^[\t ]*function[\t ]+([^\\(]+)\\([^\\)]*\\)[\t ]*$"); + QRegExp rxfun3 ("^[\t ]*function[^=]+=[\t ]*([^\s]+)[\t ]*$"); + QRegExp rxfun4 ("^[\t ]*function[\t ]+([^\s]+)[\t ]*$"); QStringList lines = _edit_area->text ().split ("\n"); for (int i = 0; i < lines.count (); i++) { if (rxfun1.indexIn (lines.at (i)) != -1) - return rxfun1.cap (3).remove (QRegExp("[ \t]*")); + return rxfun1.cap (1).remove (QRegExp("[ \t]*")); else if (rxfun2.indexIn (lines.at (i)) != -1) - return rxfun2.cap (2).remove (QRegExp("[ \t]*")); + return rxfun2.cap (1).remove (QRegExp("[ \t]*")); else if (rxfun3.indexIn (lines.at (i)) != -1) - return rxfun3.cap (3).remove (QRegExp("[ \t]*")); + return rxfun3.cap (1).remove (QRegExp("[ \t]*")); + else if (rxfun4.indexIn (lines.at (i)) != -1) + return rxfun4.cap (1).remove (QRegExp("[ \t]*")); } return QString ();