@@ -705,7 +705,7 @@ define(function (require, exports, module) {
705705 /**
706706 * Gets the current cursor position within the editor. If there is a selection, returns whichever
707707 * end of the range the cursor lies at.
708- * @param {boolean } expandTabs If true, return the actual visual column number instead of the character offset in
708+ * @param {boolean } expandTabs If true, return the actual visual column number instead of the character offset in
709709 * the "ch" property.
710710 * @return !{line:number, ch:number}
711711 */
@@ -721,7 +721,7 @@ define(function (require, exports, module) {
721721 /**
722722 * Returns the display column (zero-based) for a given string-based pos. Differs from pos.ch only
723723 * when the line contains preceding \t chars. Result depends on the current tab size setting.
724- * @param {!{line:number, ch:number} }
724+ * @param {!{line:number, ch:number} } pos
725725 * @return {number }
726726 */
727727 Editor . prototype . getColOffset = function ( pos ) {
@@ -742,11 +742,16 @@ define(function (require, exports, module) {
742742
743743 /**
744744 * Sets the cursor position within the editor. Removes any selection.
745- * @param {number } line The 0 based line number.
745+ * @param {number } line The 0 based line number.
746746 * @param {number } ch The 0 based character position; treated as 0 if unspecified.
747- * @param {boolean } center true if the view should be centered on the new cursor position
747+ * @param {boolean= } center True if the view should be centered on the new cursor position.
748+ * @param {boolean= } expandTabs If true, use the actual visual column number instead of the character offset as
749+ * the "ch" parameter.
748750 */
749- Editor . prototype . setCursorPos = function ( line , ch , center ) {
751+ Editor . prototype . setCursorPos = function ( line , ch , center , expandTabs ) {
752+ if ( expandTabs ) {
753+ ch = this . getColOffset ( { line : line , ch : ch } ) ;
754+ }
750755 this . _codeMirror . setCursor ( line , ch ) ;
751756 if ( center ) {
752757 this . centerOnCursor ( ) ;
0 commit comments