Hello, @ekopalypse, @alan-kilborn and All,
I did some additional tests, with your modifications, Alan :
line_of_first_mismatch = editor.lineFromPosition(match.span(0)[0]) notepad.messageBox('Different EOLS detected -- the first inconsistency is on line ' + str(line_of_first_mismatch + 1),'EOL Mismatch', 0)and my own one :
false_EOL = {0:'$\n|\r^', # Find \n AFTER end of line OR \r BEFORE beginning of line as editor.getEOLMode() = 0 ( Windows EOL )And everything seems to work as expected !
So the final version of this script is :
check = True false_EOL = {0:'$\n|\r^', # Find \n AFTER end of line OR \r BEFORE beginning of line as editor.getEOLMode() = 0 ( Windows EOL ) 1:'\n', # Find \n ( should be \r ) as editor.getEOLMode() = 1 ( Macintosh EOL ) 2:'\r', # Find \r ( should be \n ) as editor.getEOLMode() = 2 ( Unix EOL ) } def check_eol(match): global check check = False line_of_first_mismatch = editor.lineFromPosition(match.span(0)[0]) notepad.messageBox('Different EOLS detected -- the first inconsistency is on line ' + str(line_of_first_mismatch + 1),'EOL Mismatch', 0) user_input = notepad.prompt('Convert ALL line-endings of CURRENT file ( 0 for CRLF, 1 for CR, 2 for LF )', 'INCONSISTENT line-endings DETECTED !', editor.getEOLMode()) if user_input is not None: desired_eol_index = int(user_input) if 0 <= desired_eol_index <= 2: eol_cmd_list = [ MENUCOMMAND.FORMAT_TODOS, MENUCOMMAND.FORMAT_TOMAC, MENUCOMMAND.FORMAT_TOUNIX, ] if desired_eol_index == editor.getEOLMode(): notepad.menuCommand(eol_cmd_list[(desired_eol_index + 1) % 3]) # change to UNDESIRED line-endings notepad.menuCommand(eol_cmd_list[desired_eol_index]) # change to DESIRED line-endings editor.research(false_EOL[editor.getEOLMode()], # regex to search for check_eol, # function to call if regex match 0, # re flags 0, # START of file editor.getLength(), # END of file 1) # count ( at FIRST match ) if check == True: notepad.messageBox('All EOLS correct','EOL check', 0)To be rigorous, note that the first EOL inconsistency is always the first line with line-ending chars(s) different from the status bar indication !
Best Regards,
guy038