Closed jasonmyers closed 11 years ago
Hi again,
I looked closer into the line numbers Rope returns, and they are in fact 1-based. So instead of changing two places in the library we use (this pull request, and the one I just merged), its much better to add a simple "-1" in our own codebase, to compensate for the different indexing or Rope and ST2.
About the other issues: You're right about the regular expression and re.M, I will introduce this, and it should be reported the the Rope maintainers, since it's a real bug. Finally: why did you add the leading "\n" to the insert_import_str?
I believe I added the \n to maintain the '1 space between imports' that the +1 was causing.
So added imports come out as
import old
import new
rather than
import old
import new
I think it can be removed if you don't care about the spacing between imports
For example, after auto-import
becomes
Due to the offset + 1 in autoimport.py. Removed the +1 and changed it to a '\n' before the import statement, so that
import datetime
moves aboveclass Foo(object)
Also fixed a regex bug that wasn't finding the first class/def since re.MULTILINE was not specified (it was always processing the whole file)