Skip to content

Commit

Permalink
Fix jumpy newline above behavior
Browse files Browse the repository at this point in the history
  • Loading branch information
TheJoeFin committed Mar 4, 2024
1 parent 54202e6 commit 2208649
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions Text-Grab/Views/EditTextWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1166,10 +1166,12 @@ private void MakeQrCodeExecuted(object sender, ExecutedRoutedEventArgs e)
private void AddedLineAboveCommand(object sender, ExecutedRoutedEventArgs e)
{
int replaceCaret = PassedTextControl.CaretIndex + Environment.NewLine.Length;
int lineIndex = PassedTextControl.GetLineIndexFromCharacterIndex(PassedTextControl.CaretIndex);
int lineStart = PassedTextControl.GetCharacterIndexFromLineIndex(lineIndex);
PassedTextControl.Text = PassedTextControl.Text.Insert(lineStart, Environment.NewLine);
PassedTextControl.Select(replaceCaret, 0);
int selectionLength = PassedTextControl.SelectionLength;

SelectLine();
string lineText = PassedTextControl.SelectedText;
PassedTextControl.SelectedText = $"{Environment.NewLine}{lineText}";
PassedTextControl.Select(replaceCaret, selectionLength);
}

private void DuplicateSelectedLine(object sender, ExecutedRoutedEventArgs e)
Expand Down

0 comments on commit 2208649

Please sign in to comment.