OSDN Git Service

StatusText.TextとinReplyToを同時にセットする場合はinReplyToを先にセットする
authorKimura Youichi <kim.upsilon@bucyou.net>
Sun, 25 Sep 2016 08:04:06 +0000 (17:04 +0900)
committerKimura Youichi <kim.upsilon@bucyou.net>
Sat, 11 Nov 2017 21:06:40 +0000 (06:06 +0900)
残り文字数のカウントが inReplyTo の状態によって変化するようになったため、
StatusText_TextChanged メソッドが呼び出される時点で inReplyTo がセットされている必要がある。

Fixes: b8bb46c1 ("auto_populate_reply_metadataによって自動で付加されるメンションを抽出し、送信するtextパラメータから除去する")

OpenTween/Tween.cs

index f66deff..6ca4651 100644 (file)
@@ -6133,12 +6133,12 @@ namespace OpenTween
                         if (_hisIdx < 0) _hisIdx = 0;
 
                         var historyItem = this._history[this._hisIdx];
-                        StatusText.Text = historyItem.status;
-                        StatusText.SelectionStart = StatusText.Text.Length;
                         if (historyItem.inReplyToId != null)
                             this.inReplyTo = Tuple.Create(historyItem.inReplyToId.Value, historyItem.inReplyToName);
                         else
                             this.inReplyTo = null;
+                        StatusText.Text = historyItem.status;
+                        StatusText.SelectionStart = StatusText.Text.Length;
                     }),
 
                 ShortcutCommand.Create(Keys.Control | Keys.Down)
@@ -6154,12 +6154,12 @@ namespace OpenTween
                         if (_hisIdx > _history.Count - 1) _hisIdx = _history.Count - 1;
 
                         var historyItem = this._history[this._hisIdx];
-                        StatusText.Text = historyItem.status;
-                        StatusText.SelectionStart = StatusText.Text.Length;
                         if (historyItem.inReplyToId != null)
                             this.inReplyTo = Tuple.Create(historyItem.inReplyToId.Value, historyItem.inReplyToName);
                         else
                             this.inReplyTo = null;
+                        StatusText.Text = historyItem.status;
+                        StatusText.SelectionStart = StatusText.Text.Length;
                     }),
 
                 ShortcutCommand.Create(Keys.Control | Keys.PageUp, Keys.Control | Keys.P)
@@ -7662,22 +7662,21 @@ namespace OpenTween
                     if ((_statuses.Tabs[ListTab.SelectedTab.Text].TabType == MyCommon.TabUsageType.DirectMessage && isAuto) || (!isAuto && !isReply))
                     {
                         // ダイレクトメッセージ
+                        this.inReplyTo = null;
                         StatusText.Text = "D " + _curPost.ScreenName + " " + StatusText.Text;
                         StatusText.SelectionStart = StatusText.Text.Length;
                         StatusText.Focus();
-                        this.inReplyTo = null;
                         return;
                     }
                     if (string.IsNullOrEmpty(StatusText.Text))
                     {
                         //空の場合
-
-                        // ステータステキストが入力されていない場合先頭に@ユーザー名を追加する
-                        StatusText.Text = "@" + _curPost.ScreenName + " ";
-
                         var inReplyToStatusId = this._curPost.RetweetedId ?? this._curPost.StatusId;
                         var inReplyToScreenName = this._curPost.ScreenName;
                         this.inReplyTo = Tuple.Create(inReplyToStatusId, inReplyToScreenName);
+
+                        // ステータステキストが入力されていない場合先頭に@ユーザー名を追加する
+                        StatusText.Text = "@" + _curPost.ScreenName + " ";
                     }
                     else
                     {
@@ -7703,25 +7702,25 @@ namespace OpenTween
                                 if (StatusText.Text.StartsWith(". ", StringComparison.Ordinal))
                                 {
                                     // 複数リプライ
-                                    StatusText.Text = StatusText.Text.Insert(2, "@" + _curPost.ScreenName + " ");
                                     this.inReplyTo = null;
+                                    StatusText.Text = StatusText.Text.Insert(2, "@" + _curPost.ScreenName + " ");
                                 }
                                 else
                                 {
                                     // 単独リプライ
-                                    StatusText.Text = "@" + _curPost.ScreenName + " " + StatusText.Text;
                                     var inReplyToStatusId = this._curPost.RetweetedId ?? this._curPost.StatusId;
                                     var inReplyToScreenName = this._curPost.ScreenName;
                                     this.inReplyTo = Tuple.Create(inReplyToStatusId, inReplyToScreenName);
+                                    StatusText.Text = "@" + _curPost.ScreenName + " " + StatusText.Text;
                                 }
                             }
                             else
                             {
                                 //文頭@
                                 // 複数リプライ
+                                this.inReplyTo = null;
                                 StatusText.Text = ". @" + _curPost.ScreenName + " " + StatusText.Text;
                                 //StatusText.Text = "@" + _curPost.ScreenName + " " + StatusText.Text;
-                                this.inReplyTo = null;
                             }
                         }
                         else
@@ -7822,9 +7821,9 @@ namespace OpenTween
                             if (ids.Length == 0) return;
                             if (!StatusText.Text.StartsWith(". ", StringComparison.Ordinal))
                             {
+                                this.inReplyTo = null;
                                 StatusText.Text = ". " + StatusText.Text;
                                 sidx += 2;
-                                this.inReplyTo = null;
                             }
                             if (sidx > 0)
                             {
@@ -7885,13 +7884,13 @@ namespace OpenTween
                             if (string.IsNullOrEmpty(StatusText.Text))
                             {
                                 //未入力の場合のみ返信先付加
-                                StatusText.Text = ids;
-                                StatusText.SelectionStart = ids.Length;
-                                StatusText.Focus();
-
                                 var inReplyToStatusId = this._curPost.RetweetedId ?? this._curPost.StatusId;
                                 var inReplyToScreenName = this._curPost.ScreenName;
                                 this.inReplyTo = Tuple.Create(inReplyToStatusId, inReplyToScreenName);
+
+                                StatusText.Text = ids;
+                                StatusText.SelectionStart = ids.Length;
+                                StatusText.Focus();
                                 return;
                             }
 
@@ -10657,10 +10656,10 @@ namespace OpenTween
 
                 var selection = (this.StatusText.SelectionStart, this.StatusText.SelectionLength);
 
-                StatusText.Text += " " + MyCommon.GetStatusUrl(_curPost);
-
                 this.inReplyTo = null;
 
+                StatusText.Text += " " + MyCommon.GetStatusUrl(_curPost);
+
                 (this.StatusText.SelectionStart, this.StatusText.SelectionLength) = selection;
                 StatusText.Focus();
             }
@@ -10684,13 +10683,13 @@ namespace OpenTween
 
                 var selection = (this.StatusText.SelectionStart, this.StatusText.SelectionLength);
 
-                StatusText.Text += " RT @" + _curPost.ScreenName + ": " + rtdata;
-
                 // 投稿時に in_reply_to_status_id を付加する
                 var inReplyToStatusId = this._curPost.RetweetedId ?? this._curPost.StatusId;
                 var inReplyToScreenName = this._curPost.ScreenName;
                 this.inReplyTo = Tuple.Create(inReplyToStatusId, inReplyToScreenName);
 
+                StatusText.Text += " RT @" + _curPost.ScreenName + ": " + rtdata;
+
                 (this.StatusText.SelectionStart, this.StatusText.SelectionLength) = selection;
                 StatusText.Focus();
             }