Skip to content

Instantly share code, notes, and snippets.

@death
Created September 22, 2018 10:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save death/c7f001b0ac900d66d0ddb989318d6d09 to your computer and use it in GitHub Desktop.
Save death/c7f001b0ac900d66d0ddb989318d6d09 to your computer and use it in GitHub Desktop.
Cluffer issue
(let* ((line (make-instance 'cluffer-simple-line:line))
(buffer (make-instance 'cluffer-simple-buffer:buffer
:initial-line line))
(cursor (make-instance 'cluffer-simple-line:right-sticky-cursor)))
(declare (ignore buffer))
(cluffer:attach-cursor cursor line)
(cluffer:insert-item cursor #\1)
(cluffer:split-line cursor)
(cluffer:join-line line)
(cluffer:insert-item cursor #\2)
(values (cluffer:items line)
(cluffer:line-number (cluffer:line cursor))
(cluffer:cursor-position cursor)))
;; ==> #(#\1 #\2)
;; 0
;; 1
;; The cursor position should be 2, not 1. The problem is that
;; join-line does not update the line's cursors list. Patch:
#||
diff --git a/Simple-line/edit-protocol-implementation.lisp b/Simple-line/edit-protocol-implementation.lisp
index 23640e6..3030087 100644
--- a/Simple-line/edit-protocol-implementation.lisp
+++ b/Simple-line/edit-protocol-implementation.lisp
@@ -116,6 +116,7 @@
(loop with length = (length (contents line1))
for cursor in (cursors line2)
do (setf (line cursor) line1)
+ (push cursor (cursors line1))
(incf (cluffer:cursor-position cursor) length))
(setf (contents line1)
(concatenate 'vector (contents line1) (contents line2)))
diff --git a/Standard-line/edit-protocol-implementation.lisp b/Standard-line/edit-protocol-implementation.lisp
index 73b66ba..2f5bafc 100644
--- a/Standard-line/edit-protocol-implementation.lisp
+++ b/Standard-line/edit-protocol-implementation.lisp
@@ -244,6 +244,7 @@
(loop with length = (length (contents line1))
for cursor in (cursors line2)
do (setf (line cursor) line1)
+ (push cursor (cursors line1))
(incf (cluffer:cursor-position cursor) length))
(setf (contents line1)
(concatenate 'vector (contents line1) (contents line2)))
||#
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment