exabugs / WebIDE

0 stars 0 forks source link

コードが編集されるとスクロールが先頭に来てしまう #7

Closed exabugs closed 6 years ago

exabugs commented 6 years ago

d1e0b1e0e97d6d274aeeeca87a62c47f148e7e82

XEdit/XEdit.js

  updateCode(code, line) {
    const value = this.cm.getDoc().getValue();
    if (value !== code) {
      this.setState({ initialized: false }); // 更新イベントを停止
      this.cm.getDoc().setValue(code);
    } else {
      console.log('updateCode : No changed.');
    }

    if (line !== undefined) {
      this.setLine(line);
    } else {
      this.cursorLoad();// カーソル位置を再現する
      this.scrollLoad();// スクロール位置を再現する
    }
    this.setState({ initialized: true }); // 更新イベントを再開
  }