Skip to content

Commit b595be5

Browse files
committed
adjust range-indentation so that, after indentation, it moves
the insertion point to the first nonwhitespace on the line (in the case that there is an insertion point instead of a selection)
1 parent 643d228 commit b595be5

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

drracket-core-lib/drracket/private/module-language-tools.rkt

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,7 @@
216216
(mixin (text:basic<%>) (ml-tools-text<%>)
217217
(inherit position-paragraph paragraph-start-position
218218
delete insert
219+
set-position paragraph-end-position get-character
219220
begin-edit-sequence end-edit-sequence)
220221
(define/public (range-indent range-indentation-function start end)
221222
(define substs (range-indentation-function this start end))
@@ -234,6 +235,16 @@
234235
(delete pos (+ pos del-amt)))
235236
(unless (equal? insert-str "")
236237
(insert insert-str pos))
238+
(when (= start end)
239+
(define para-end (paragraph-end-position start-line))
240+
(let loop ([pos pos])
241+
(cond
242+
[(< pos para-end)
243+
(define c (get-character pos))
244+
(cond
245+
[(char-whitespace? c) (loop (+ pos 1))]
246+
[else (set-position pos pos)])]
247+
[else (void)])))
237248
(loop (cdr substs) (add1 line))))
238249
(end-edit-sequence)
239250
#t)))

0 commit comments

Comments
 (0)