matstc avatar matstc committed 2b92d4f

fixed column number when using visual line mode

There was a bug for me in ropevim: I could not use visual line mode to select
stuff to refactor for RopeRefactorMethod or RopeRefactorVariable. Somehow, the
column number for the mark '>' was 2147483647 when using visual line mode. I
worked around that in #_position_to_offset.

Comments (0)

Files changed (1)

         return result
 
     def _position_to_offset(self, lineno, colno):
-        result = colno
+        result = min(colno, len(self.buffer[lineno -1]) + 1)
         for line in self.buffer[:lineno-1]:
             result += len(line) + 1
         return result
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.