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