Mercurial > hg > octave-nkf
diff libgui/src/m-editor/file-editor-tab.cc @ 19197:bf7c5d96d1ff gui-release
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
author | Torsten <ttl@justmail.de> |
---|---|
date | Mon, 11 Aug 2014 19:28:08 +0200 |
parents | e87e65bc71ae |
children | 2e6b34324d50 |
line wrap: on
line diff
--- a/libgui/src/m-editor/file-editor-tab.cc +++ b/libgui/src/m-editor/file-editor-tab.cc @@ -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 ();