@@ -902,7 +902,18 @@ void Buffer_nextPage(Buffer* this) {
902902 this -> selecting = false;
903903}
904904
905- void Buffer_wordWrap (Buffer * this , int wrap ) {
905+ void Buffer_wordWrap (Buffer * this , int wrap , int indent ) {
906+ if (indent == -1 ) {
907+ indent = 0 ;
908+ for (int i = 0 ; i < last_x (this ); i ++ ) {
909+ int ch = Line_charAt (this -> line , i );
910+ if (ch == ' ' || ch == '*' ) {
911+ indent ++ ;
912+ } else {
913+ break ;
914+ }
915+ }
916+ }
906917 Undo_beginGroup (this -> undo , this -> x , this -> y );
907918 int minLen = this -> dosLineBreaks ? 1 : 0 ;
908919 while (this -> line -> super .next && Line_chars ((Line * )this -> line -> super .next ) > minLen ) {
@@ -919,7 +930,7 @@ void Buffer_wordWrap(Buffer* this, int wrap) {
919930 Buffer_deleteChar (this );
920931 }
921932 this -> line = (Line * ) Panel_getSelected (this -> panel );
922- Buffer_wordWrap (this , wrap );
933+ Buffer_wordWrap (this , wrap , indent );
923934 }
924935 while (last_x (this ) > wrap ) {
925936 Line * oldLine = this -> line ;
@@ -928,6 +939,11 @@ void Buffer_wordWrap(Buffer* this, int wrap) {
928939 this -> x = i ;
929940 Buffer_deleteChar (this );
930941 Buffer_breakLine (this );
942+ if (indent > 0 ) {
943+ for (int j = 0 ; j < indent ; j ++ ) {
944+ Buffer_defaultKeyHandler (this , ' ' , false);
945+ }
946+ }
931947 break ;
932948 }
933949 }
0 commit comments