mirror of
https://github.com/SubtitleEdit/subtitleedit.git
synced 2024-11-22 11:12:36 +01:00
[internal] - introduce more constant for var inside loop
This commit is contained in:
parent
919ef34555
commit
a98a00e13c
@ -215,7 +215,7 @@ namespace Nikse.SubtitleEdit.Core
|
||||
if (makeUppercaseAfterBreak && StrippedText.Contains(new[] { '.', '!', '?', ':', ';', ')', ']', '}', '(', '[', '{' }))
|
||||
{
|
||||
const string breakAfterChars = @".!?:;)]}([{";
|
||||
|
||||
const string ExpectedChars = "\"`´'()<>!?.- \r\n";
|
||||
var sb = new StringBuilder();
|
||||
bool lastWasBreak = false;
|
||||
for (int i = 0; i < StrippedText.Length; i++)
|
||||
@ -223,7 +223,7 @@ namespace Nikse.SubtitleEdit.Core
|
||||
var s = StrippedText[i];
|
||||
if (lastWasBreak)
|
||||
{
|
||||
if (("\"`´'()<>!?.- " + Environment.NewLine).Contains(s))
|
||||
if (ExpectedChars.Contains(s))
|
||||
{
|
||||
sb.Append(s);
|
||||
}
|
||||
|
@ -87,18 +87,19 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
{
|
||||
if (word != null && richTextBoxParagraph.Text.Contains(word))
|
||||
{
|
||||
const string ExpectedWordBoundaryChars = @" <>-""”“[]'‘`´¶()♪¿¡.…—!?,:;/\r\n";
|
||||
for (int i = 0; i < richTextBoxParagraph.Text.Length; i++)
|
||||
{
|
||||
if (richTextBoxParagraph.Text.Substring(i).StartsWith(word))
|
||||
{
|
||||
bool startOk = i == 0;
|
||||
if (!startOk)
|
||||
startOk = (@" <>-""”“[]'‘`´¶()♪¿¡.…—!?,:;/" + Environment.NewLine).Contains(richTextBoxParagraph.Text[i - 1]);
|
||||
startOk = ExpectedWordBoundaryChars.Contains(richTextBoxParagraph.Text[i - 1]);
|
||||
if (startOk)
|
||||
{
|
||||
bool endOk = (i + word.Length == richTextBoxParagraph.Text.Length);
|
||||
if (!endOk)
|
||||
endOk = (@" <>-""”“[]'‘`´¶()♪¿¡.…—!?,:;/" + Environment.NewLine).Contains(richTextBoxParagraph.Text[i + word.Length]);
|
||||
endOk = ExpectedWordBoundaryChars.Contains(richTextBoxParagraph.Text[i + word.Length]);
|
||||
if (endOk)
|
||||
{
|
||||
richTextBoxParagraph.SelectionStart = i + 1;
|
||||
|
Loading…
Reference in New Issue
Block a user