OSDN Git Service

「URLからの全角文字列の切り離し」のテストケースを追加
authorKimura Youichi <kim.upsilon@bucyou.net>
Thu, 14 Dec 2023 18:35:50 +0000 (03:35 +0900)
committerKimura Youichi <kim.upsilon@bucyou.net>
Thu, 14 Dec 2023 19:02:38 +0000 (04:02 +0900)
OpenTween.Tests/TweenMainTest.cs
OpenTween/Tween.cs

index 8127d10..01e7f73 100644 (file)
@@ -83,6 +83,26 @@ namespace OpenTween
         }
 
         [WinFormsFact]
+        public void FormatStatusText_SeparateUrlAndFullwidthCharacter_EnabledTest()
+        {
+            this.UsingTweenMain((tweenMain, context) =>
+            {
+                tweenMain.SeparateUrlAndFullwidthCharacter = true;
+                Assert.Equal("https://example.com/ あああ", tweenMain.FormatStatusText("https://example.com/あああ"));
+            });
+        }
+
+        [WinFormsFact]
+        public void FormatStatusText_SeparateUrlAndFullwidthCharacter_DisabledTest()
+        {
+            this.UsingTweenMain((tweenMain, context) =>
+            {
+                tweenMain.SeparateUrlAndFullwidthCharacter = false;
+                Assert.Equal("https://example.com/あああ", tweenMain.FormatStatusText("https://example.com/あああ"));
+            });
+        }
+
+        [WinFormsFact]
         public void FormatStatusText_ReplaceFullwidthSpace_EnabledTest()
         {
             this.UsingTweenMain((tweenMain, context) =>
index 879f13f..8ae352b 100644 (file)
@@ -208,7 +208,9 @@ namespace OpenTween
         private readonly DebounceTimer saveConfigDebouncer;
 
         private readonly string recommendedStatusFooter;
-        private bool urlMultibyteSplit = false;
+
+        internal bool SeparateUrlAndFullwidthCharacter { get; set; } = false;
+
         private bool preventSmsCommand = true;
 
         // URL短縮のUndo用
@@ -3535,7 +3537,7 @@ namespace OpenTween
         {
             statusText = statusText.Replace("\r\n", "\n");
 
-            if (this.urlMultibyteSplit)
+            if (this.SeparateUrlAndFullwidthCharacter)
             {
                 // URLと全角文字の切り離し
                 statusText = Regex.Replace(statusText, @"https?:\/\/[-_.!~*'()a-zA-Z0-9;\/?:\@&=+\$,%#^]+", "$& ");
@@ -8193,7 +8195,7 @@ namespace OpenTween
         }
 
         private void UrlMultibyteSplitMenuItem_CheckedChanged(object sender, EventArgs e)
-            => this.urlMultibyteSplit = ((ToolStripMenuItem)sender).Checked;
+            => this.SeparateUrlAndFullwidthCharacter = ((ToolStripMenuItem)sender).Checked;
 
         private void PreventSmsCommandMenuItem_CheckedChanged(object sender, EventArgs e)
             => this.preventSmsCommand = ((ToolStripMenuItem)sender).Checked;
@@ -8215,7 +8217,7 @@ namespace OpenTween
 
         private void PostModeMenuItem_DropDownOpening(object sender, EventArgs e)
         {
-            this.UrlMultibyteSplitMenuItem.Checked = this.urlMultibyteSplit;
+            this.UrlMultibyteSplitMenuItem.Checked = this.SeparateUrlAndFullwidthCharacter;
             this.PreventSmsCommandMenuItem.Checked = this.preventSmsCommand;
             this.UrlAutoShortenMenuItem.Checked = this.settings.Common.UrlConvertAuto;
             this.IdeographicSpaceToSpaceMenuItem.Checked = this.settings.Common.WideSpaceConvert;
@@ -8225,7 +8227,7 @@ namespace OpenTween
 
         private void ContextMenuPostMode_Opening(object sender, CancelEventArgs e)
         {
-            this.UrlMultibyteSplitPullDownMenuItem.Checked = this.urlMultibyteSplit;
+            this.UrlMultibyteSplitPullDownMenuItem.Checked = this.SeparateUrlAndFullwidthCharacter;
             this.PreventSmsCommandPullDownMenuItem.Checked = this.preventSmsCommand;
             this.UrlAutoShortenPullDownMenuItem.Checked = this.settings.Common.UrlConvertAuto;
             this.IdeographicSpaceToSpacePullDownMenuItem.Checked = this.settings.Common.WideSpaceConvert;