@@ -541,19 +541,45 @@ public class Notejot.NoteContentView : View {
541541 var text_buffer = text_view. get_buffer();
542542 string text;
543543 int text_length = 0 ;
544- Gtk . TextIter start, end, cursor_iter;
544+ Gtk . TextIter start, end, starts, ends, cursor_iter;
545545 text_buffer. get_selection_bounds(out start, out end);
546546
547547 if (text_buffer. get_has_selection()) {
548- if (start. starts_line()){
549- text = text_buffer. get_text(start, end, false );
550- if (text. has_prefix(" - " )){
551- var delete_end = start. copy();
552- delete_end. forward_chars(2 );
553- text_buffer. delete(ref start, ref delete_end);
554- } else {
555- text_buffer. insert(ref start, " - " , - 1 );
548+ text = text_buffer. get_text(start, end, false );
549+ if (text. has_prefix(" - " )){
550+ var lines = text. strip (). split(" \n " );
551+ string list_line = " " ;
552+
553+ foreach (var line in lines) {
554+ if (line == lines[0 ]) {
555+ list_line + = line. replace(" - " , " " );
556+ } else {
557+ list_line + = " \n " + line. replace(" - " , " " );
558+ }
559+ }
560+ text_buffer. insert(ref start, list_line, - 1 );
561+
562+ text_buffer. get_selection_bounds(out starts, out ends);
563+ text_buffer. delete(ref starts, ref ends);
564+
565+ select_text(text_view, 0 , list_line. length);
566+ } else {
567+ var lines = text. strip (). split(" \n " );
568+ string list_line = " " ;
569+
570+ foreach (var line in lines) {
571+ if (line == lines[0 ]) {
572+ list_line + = " - " + line;
573+ } else {
574+ list_line + = " \n " + " - " + line;
575+ }
556576 }
577+ text_buffer. insert(ref start, list_line, - 1 );
578+
579+ text_buffer. get_selection_bounds(out starts, out ends);
580+ text_buffer. delete(ref starts, ref ends);
581+
582+ select_text(text_view, 0 , list_line. length);
557583 }
558584 } else {
559585 helptext = _(" Item" );
0 commit comments