Skip to content

Commit

Permalink
Fix problem with edit mismatch on server vs. client
Browse files Browse the repository at this point in the history
  • Loading branch information
mlavrent authored and jeapostrophe committed Dec 24, 2020
1 parent 55dc070 commit 767741b
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion text-document.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
racket/match
racket/string
racket/set
racket/gui
syntax-color/module-lexer
syntax-color/racket-lexer
"append-message.rkt"
Expand Down Expand Up @@ -304,11 +305,15 @@
(define end-pos (Pos->abs-pos doc-text end))
(define start-line (send doc-text position-paragraph start-pos))
(define end-line (send doc-text position-paragraph end-pos))
(define mut-doc-text
(if (is-a? doc-text racket:text%)
(let ([r-text (new racket:text%)]) (send r-text insert (send doc-text get-text)) r-text)
(send doc-text copy-self)))
(define results
(let loop ([line start-line])
(if (> line end-line)
null
(let ([edit (indent-line! doc-text indenter line)])
(let ([edit (indent-line! mut-doc-text indenter line)])
(if edit
(cons edit (loop (add1 line)))
(loop (add1 line)))))))
Expand Down Expand Up @@ -338,11 +343,13 @@
(define insert-count (- desired-spaces current-spaces))
(define new-text (make-string insert-count #\space))
(define pos (Pos #:line line #:char 0))
(send doc-text insert new-text line-start 'same)
(TextEdit #:range (Range #:start pos #:end pos)
#:newText new-text)]
[else
;; Delete spaces
(define span (- current-spaces desired-spaces))
(send doc-text delete line-start (+ line-start span))
(TextEdit #:range (Range #:start (Pos #:line line #:char 0)
#:end (Pos #:line line #:char span))
#:newText "")]))
Expand Down

0 comments on commit 767741b

Please sign in to comment.