Mercurial > hg > RemoteEditor > vim7
changeset 28:24808249e776
*** empty log message ***
author | kono |
---|---|
date | Tue, 28 Oct 2008 00:55:29 +0900 |
parents | a01d8d9b2a58 |
children | ef6d2a18d7c2 |
files | src/REPNOTE.txt src/reditor.c |
diffstat | 2 files changed, 48 insertions(+), 23 deletions(-) [+] |
line wrap: on
line diff
--- a/src/REPNOTE.txt Mon Oct 27 18:28:11 2008 +0900 +++ b/src/REPNOTE.txt Tue Oct 28 00:55:29 2008 +0900 @@ -1,3 +1,8 @@ +Tue Oct 28 00:40:44 JST 2008 + +mode change の最初のml_replace で、delete command が出てない。 +delete command のasserttion がfailすることがある。 + Mon Oct 27 15:53:19 JST 2008 直せば直すほど、動かなくなってくる。joinのsessionが変らしい。
--- a/src/reditor.c Mon Oct 27 18:28:11 2008 +0900 +++ b/src/reditor.c Tue Oct 28 00:55:29 2008 +0900 @@ -78,6 +78,8 @@ /* g_rep has an all information of Remote Editor */ static rep_T g_rep; +int lock_editor = 0; + /* * Wrapper for vim */ @@ -199,13 +201,21 @@ permit = rep->permit; rep->permit = FALSE; - r = ml_append(lnum-1, (char_u*)text, strlen(text)+1, FALSE); - appended_lines_mark(lnum-1,1); + r = ml_append(lnum, (char_u*)text, strlen(text)+1, FALSE); + appended_lines_mark(lnum,1); rep->permit = permit; return r; } +/* 編集中のバッファの行数を返す */ +long +get_bufmaxline_wrp(buf) + BUFTYPE *buf; +{ + return buf->b_ml.ml_line_count; +} + /* 編集中のバッファの行の削除 */ static int delete_memline_wrp(lnum) @@ -218,8 +228,10 @@ permit = rep->permit; rep->permit = FALSE; - r = ml_delete(lnum, FALSE); - deleted_lines_mark(lnum,1); + int maxline = get_bufmaxline_wrp(get_curbuf_wrp()); + if (lnum+1>maxline) return 0; + r = ml_delete(lnum+1, FALSE); + deleted_lines_mark(lnum+1,1); rep->permit = permit; return r; @@ -234,14 +246,6 @@ return; } -/* 編集中のバッファの行数を返す */ -long -get_bufmaxline_wrp(buf) - BUFTYPE *buf; -{ - return buf->b_ml.ml_line_count; -} - /* get full path of buffer */ static char * @@ -842,8 +846,7 @@ cursn = rep->cursession; - // 既にコピーしていたら、何もしない - if ((cursn == NULL) || (cursn->prevline == -1)) + if (cursn == NULL) return; // バッファが変更された場合には rep->cursession も合わす @@ -867,9 +870,14 @@ char *text = get_memline_wrp(cursn->buf, lnum); unsigned int length = strlen(text); cmd = make_cmd(REPCMD_DELETE, cursn->sid, rep->eid, rep->seqno++, - cursn->prevline, length, text); + cursn->prevline-1, length, text); rep_send_cmd(rep->smfd,cmd); rep_free(cmd); + if (cursn->del_cmd) { + // Cancel delete cmd + rep_free(cursn->del_cmd); + cursn->del_cmd = 0; + } } else if (xtr==0) { // ml_replace case if (cursn->del_cmd) @@ -877,7 +885,7 @@ char *text = get_memline_wrp(cursn->buf, lnum); unsigned int length = strlen(text); cursn->del_cmd = make_cmd(REPCMD_DELETE, cursn->sid, rep->eid, - rep->seqno++, cursn->prevline, length, text); + rep->seqno++, cursn->prevline-1, length, text); } else { // ml_append case @@ -885,6 +893,10 @@ } } +/* + * channged_common から呼ばれて、変更をREP commandに直して + * 送信する。 + */ void rep_register(lnum, lnume, xtra) unsigned int lnum; @@ -918,7 +930,7 @@ unsigned int length = strlen(text); // make INSERT_CMD for insert or changed lines if any cmd = make_cmd(REPCMD_INSERT, cursn->sid, rep->eid, rep->seqno++, - i+1, length, text); + i, length, text); rep_send_cmd(rep->smfd,cmd); free_cmd(cmd); } @@ -941,7 +953,7 @@ char *text = get_memline_wrp(cursn->buf, lnum); unsigned int length = strlen(text); cmd = make_cmd(REPCMD_INSERT, cursn->sid, rep->eid, rep->seqno++, - cursn->prevline, length,text); + cursn->prevline-1, length,text); rep_send_cmd(rep->smfd,cmd); // reuse cmd // save current line for next replace @@ -1016,13 +1028,13 @@ } static void -addNop(Session *session, rep_T *rep) +addNop(int sid, rep_T *rep) { int fd = rep->smfd; - char *packet = rep->nop->pkt; + char *packet = &rep->nop->pkt[0]; if (rep->prevSeq==rep->seqno) { - set_header(session->sid, packet, REP_SID_OFFSET); + set_header(sid, packet, REP_SID_OFFSET); set_header(rep->eid, packet, REP_EID_OFFSET); set_header(rep->seqno, packet, REP_SEQNUM_OFFSET); rep->prevSeq = rep->seqno; @@ -1053,6 +1065,8 @@ char *msg = alloca(150); sprintf(msg,"joined eid=%d sid=%d",rep->eid,session->sid); e_msg_wrp(msg); + + rep->prevSeq = rep->seqno; } break; @@ -1069,12 +1083,14 @@ char *msg = alloca(150); sprintf(msg,"put eid=%d sid=%d",rep->eid,session->sid); e_msg_wrp(msg); + + rep->prevSeq = rep->seqno; } break; case REPCMD_INSERT: append_memline_wrp(command->lnum, text); - if (eid!=MERGE_EID) addNop(session, rep); + if (eid!=MERGE_EID) addNop(command->sid, rep); forwardCommand(rep,command); if (eid!=MERGE_EID) update_screen_now_wrp(); break; @@ -1082,7 +1098,7 @@ delete_memline_wrp(command->lnum); if (eid!=MERGE_EID) update_screen_now_wrp(); case REPCMD_NOP: - if (eid!=MERGE_EID) addNop(session, rep); + if (eid!=MERGE_EID) addNop(command->sid, rep); forwardCommand(rep,command); break; case SMCMD_SYNC: @@ -1094,8 +1110,12 @@ forwardCommand(rep,command); break; case SMCMD_START_MERGE: + lock_editor = 1; + set_cmd_seq(command,SMCMD_START_MERGE_ACK,rep->seqno++); + forwardCommand(rep,command); break; case SMCMD_END_MERGE: + lock_editor = 0; rep->prevSeq = rep->seqno; update_screen_now_wrp(); default: