Skip to content

Commit

Permalink
lua editor trailing fix
Browse files Browse the repository at this point in the history
Fixes an issue where the caret gets positioned wrong after removing white spaces
  • Loading branch information
blancoberg committed Dec 4, 2024
1 parent 1adcebf commit 62ded68
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/surge-xt/gui/overlays/LuaEditors.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,13 @@ void CodeEditorContainerWithApply::removeTrailingWhitespaceFromDocument()
{
juce::CodeDocument::Position lineStart{mainEditor->getDocument(), i, 0};
auto s = lineStart.getLineText();
const auto sizeOld = s.length() - 1; // disregard EOL

int eol = 1;
if (s.contains("\r\n"))
{
eol = 2;
}
const auto sizeOld = s.length() - eol; // disregard EOL
juce::CodeDocument::Position lineEnd{mainEditor->getDocument(), i, sizeOld};

s = s.trimEnd();
Expand Down

0 comments on commit 62ded68

Please sign in to comment.