Menu

Unwanted recursive behaviour

Help
2014-06-18
2014-06-19
  • Gunnar Bennemann

    Instead of removal of trailing blanks and tabs, the script adds empty lines repeatedly after the first one. Only stoppable by close of window, strange behaviour by NP++ after then.

    def form(cont, lino, linum) :
        """
        for all lines :
            delete all leading blanks and tabs
        """
        console.write('\n[%s], %d, %d' % (cont[:-1], lino, linum))
        editor.replaceLine(lino, cont[:-1].lstrip(" \t"))
        return 1

    editor.forEachLine(form)

    PythonScript 1.0.5.0 & NP++ v6.6.6 used

     
  • Gunnar Bennemann

    2nd attempt works today :-)
    Instead of
    editor.replaceLine(lino, cont[:-1].lstrip(" \t"))
    I used
    editor.replaceWholeLine(lino, cont.lstrip(" \t"))

    Guess recursion comes from, that the script failed to position to the next line.

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.