eteran / nedit-ng

a Qt5 port of the NEdit using modern C++14
GNU General Public License v2.0
95 stars 26 forks source link

macro execution stopped #338

Closed marilmanen closed 1 year ago

marilmanen commented 1 year ago

Here is an macro that stops with a pop-up message. It greps given string from files in current directory and allows user to open a file from the line containing the string.

if ($selection_start > -1) {
    string = get_selection()
} else {
    string = string_dialog("Give string to grep")
}
matches = shell_command("grep -ni '" string "' * |& grep -v '^grep: '", "")
if ( matches == "" ) {
    dialog("No matches found for " string)
}
selection = 1
while ( selection != "" && matches != "" ) {
  selection = list_dialog( "Select one of the matching lines___________________________________________________________________________________________________________________________________________________________________________________________________________", matches )
  if ( selection != "" ) {
    file = selection
    file = replace_in_string(file, ":.*", "", "regex")
    line = selection
    line = replace_in_string(line, ":\\D.*", "", "regex")
    line = replace_in_string(line, ".*:", "", "regex")
    if ( ( file == "") || ( line == "" ) ) {
      dialog("Something wrong with this macro: " selection "--" file "__" line, "OK")
    } else {
      open($file_path file)
      focus_window($file_path file)
      goto_line_number(line)
    }
  }
  matches = shell_command("grep -ni '" string "' * |& grep -v '^grep: '", "")
}
eteran commented 1 year ago

OK, I see the issue triggers once you select a file to open. Which appears to succeed... but then you get this popup.

I'll check it out!

eteran commented 1 year ago

@marilmanen I believe it should be fixed now :-)