@@ -791,15 +791,24 @@ void SurgeCodeEditorComponent::caretPositionMoved()
791
791
}
792
792
}
793
793
794
+ void SurgeCodeEditorComponent::mouseWheelMove (const juce::MouseEvent &e,
795
+ const juce::MouseWheelDetails &wheel)
796
+ {
797
+ juce::MouseWheelDetails w (wheel);
798
+ w.deltaY *= 4 ;
799
+ CodeEditorComponent::mouseWheelMove (e, w);
800
+ }
801
+
794
802
// Handles auto indentation
795
803
796
804
void SurgeCodeEditorComponent::handleReturnKey ()
797
805
{
798
-
799
806
auto pos = this ->getCaretPos ();
800
807
auto txt = pos.getLineText ();
801
808
int tabs = 0 ;
802
-
809
+ int indexInLine = pos.getIndexInLine ();
810
+ int actualCharactersBeforeCaret = 0 ;
811
+ bool indent = false ;
803
812
for (int i = 0 ; i < txt.length (); i++)
804
813
{
805
814
if (txt.substring (i, i + 1 ) == " " )
@@ -812,7 +821,7 @@ void SurgeCodeEditorComponent::handleReturnKey()
812
821
}
813
822
else
814
823
{
815
- bool indent = false ;
824
+
816
825
auto trimmedTxt = txt.trim ();
817
826
818
827
if (txt.substring (i, i + 8 ) == " function" )
@@ -839,10 +848,17 @@ void SurgeCodeEditorComponent::handleReturnKey()
839
848
840
849
break ;
841
850
}
851
+
852
+ if (i < indexInLine)
853
+ {
854
+ actualCharactersBeforeCaret = tabs;
855
+ }
842
856
}
843
857
844
858
this ->insertTextAtCaret (" \n " );
845
- this ->insertTextAtCaret (std::string (tabs, ' ' ));
859
+ this ->insertTextAtCaret (std::string (
860
+ std::min (actualCharactersBeforeCaret + (indent == true ? this ->getTabSize () : 0 ), tabs),
861
+ ' ' ));
846
862
}
847
863
848
864
struct EditorColors
@@ -1135,7 +1151,6 @@ bool CodeEditorContainerWithApply::autoCompleteStringDeclaration(juce::String st
1135
1151
mainEditor->insertTextAtCaret (str);
1136
1152
}
1137
1153
return true ;
1138
- // sdfsd
1139
1154
}
1140
1155
1141
1156
void CodeEditorContainerWithApply::paint (juce::Graphics &g) { g.fillAll (juce::Colours::black); }
@@ -3003,4 +3018,4 @@ WavetableScriptEditor::getPreCloseChickenBoxMessage()
3003
3018
}
3004
3019
3005
3020
} // namespace Overlays
3006
- } // namespace Surge
3021
+ } // namespace Surge
0 commit comments