Why the function of editor.setCursor(line,column) not work fine

I want when I submit the form to set the cursor of codemirror at the same last position befour submit
I write this
var lastpo=0;
var ln;

    var editor = CodeMirror.fromTextArea(document.getElementById("preview-form-comment"), {
    lineNumbers: true,
    matchBrackets: true,
    //autofocus:true,
    mode: "mymode",
    indentUnit: 4,
    autoCloseBrackets: true,
    highlightSelectionMatches: true,
    styleActiveLine: true,
    extraKeys: {
        "Ctrl-Space": "autocomplete",
        "Ctrl-Space":function(cm){  CodeMirror.showHint(cm, CodeMirror.hint.anyword); },
        "'.'" : "autocomplete" ,
       // "'.'" :function(cm){  CodeMirror.showHint(cm, CodeMirror.hint.anyword); },
    },
    autohint: true,
    readOnly: false,
    lineWrapping: true,

    }); 
    editor.focus();
    window.lastpo=localStorage.getItem("valueofcursor");
    editor.setCursor({line: 1, ch: window.lastpo});
    alert(window.lastpo);

Note : window.lastpo give the true position but the editor.setCursor not work fine …
this work fine when the last position before submit is the last character in line … But when I put the Cursor in middle line for example and do submit it set the Cursor in the end of line I want to set it in the same position befor I submit not in the end of line … so what I hve to do ?

Line numbers are 0-based by default, so your hard-coded 1 probably doesn’t mean what you think it means.

ok the problem in line I solved thank you ? @marijn