From: Kimura Youichi Date: Thu, 14 Dec 2023 18:35:50 +0000 (+0900) Subject: 「URLからの全角文字列の切り離し」のテストケースを追加 X-Git-Tag: OpenTween_v3.10.0^2~2^2~2 X-Git-Url: http://git.osdn.net/view?p=opentween%2Fopen-tween.git;a=commitdiff_plain;h=45b33f4b1a348b51312329b7239e3f6b1fa7b213 「URLからの全角文字列の切り離し」のテストケースを追加 --- diff --git a/OpenTween.Tests/TweenMainTest.cs b/OpenTween.Tests/TweenMainTest.cs index 8127d105..01e7f73f 100644 --- a/OpenTween.Tests/TweenMainTest.cs +++ b/OpenTween.Tests/TweenMainTest.cs @@ -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) => diff --git a/OpenTween/Tween.cs b/OpenTween/Tween.cs index 879f13fa..8ae352ba 100644 --- a/OpenTween/Tween.cs +++ b/OpenTween/Tween.cs @@ -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;