mirror of
https://github.com/m00natic/vlfi.git
synced 2025-01-31 10:10:48 +00:00
Prevent inserting of too small file regions for GNU Emacs later than
24.3.
This commit is contained in:
parent
4f99eaa5e7
commit
161a4ec76e
17
vlf.el
17
vlf.el
@ -491,10 +491,13 @@ bytes added to the end."
|
|||||||
(vlf-with-undo-disabled
|
(vlf-with-undo-disabled
|
||||||
(delete-region del-pos (point-max)))))
|
(delete-region del-pos (point-max)))))
|
||||||
((< edit-end end)
|
((< edit-end end)
|
||||||
|
(if (and (not vlf-partial-decode-shown)
|
||||||
|
(< (- end vlf-end-pos) 4))
|
||||||
|
(setq end vlf-end-pos)
|
||||||
(vlf-with-undo-disabled
|
(vlf-with-undo-disabled
|
||||||
(setq shift-end (cdr (vlf-insert-file-contents
|
(setq shift-end (cdr (vlf-insert-file-contents
|
||||||
vlf-end-pos end nil t
|
vlf-end-pos end nil t
|
||||||
(point-max)))))))
|
(point-max))))))))
|
||||||
(cond ((< vlf-start-pos start)
|
(cond ((< vlf-start-pos start)
|
||||||
(let* ((del-pos (1+ (byte-to-position
|
(let* ((del-pos (1+ (byte-to-position
|
||||||
(- start vlf-start-pos))))
|
(- start vlf-start-pos))))
|
||||||
@ -506,14 +509,17 @@ bytes added to the end."
|
|||||||
(vlf-with-undo-disabled
|
(vlf-with-undo-disabled
|
||||||
(delete-region (point-min) del-pos))))
|
(delete-region (point-min) del-pos))))
|
||||||
((< start vlf-start-pos)
|
((< start vlf-start-pos)
|
||||||
|
(if (and (not vlf-partial-decode-shown)
|
||||||
|
(< (- vlf-start-pos start) 4))
|
||||||
|
(setq start vlf-start-pos)
|
||||||
(let ((edit-end-pos (point-max)))
|
(let ((edit-end-pos (point-max)))
|
||||||
(vlf-with-undo-disabled
|
(vlf-with-undo-disabled
|
||||||
(setq shift-start (car (vlf-insert-file-contents
|
(setq shift-start (car (vlf-insert-file-contents
|
||||||
start vlf-start-pos
|
start vlf-start-pos
|
||||||
t nil edit-end-pos)))
|
t nil edit-end-pos)))
|
||||||
(goto-char (point-min))
|
(goto-char (point-min))
|
||||||
(insert (delete-and-extract-region edit-end-pos
|
(insert (delete-and-extract-region
|
||||||
(point-max)))))))
|
edit-end-pos (point-max))))))))
|
||||||
(setq start (- start shift-start))
|
(setq start (- start shift-start))
|
||||||
(goto-char (or (byte-to-position (- pos start))
|
(goto-char (or (byte-to-position (- pos start))
|
||||||
(byte-to-position (- pos vlf-start-pos))
|
(byte-to-position (- pos vlf-start-pos))
|
||||||
@ -575,8 +581,9 @@ ADJUST-END is non-nil if end would be adjusted later.
|
|||||||
Return number of bytes moved back for proper decoding."
|
Return number of bytes moved back for proper decoding."
|
||||||
(let* ((min-end (min end (+ start vlf-min-chunk-size)))
|
(let* ((min-end (min end (+ start vlf-min-chunk-size)))
|
||||||
(chunk-size (- min-end start))
|
(chunk-size (- min-end start))
|
||||||
|
(strict (and (not adjust-end) (= min-end end)))
|
||||||
(shift (vlf-insert-content-safe start min-end position t)))
|
(shift (vlf-insert-content-safe start min-end position t)))
|
||||||
(setq start (+ start shift))
|
(setq start (- start shift))
|
||||||
(while (and (not (zerop start))
|
(while (and (not (zerop start))
|
||||||
(< shift 3)
|
(< shift 3)
|
||||||
(let ((diff (- chunk-size
|
(let ((diff (- chunk-size
|
||||||
@ -584,7 +591,7 @@ Return number of bytes moved back for proper decoding."
|
|||||||
(encode-coding-region
|
(encode-coding-region
|
||||||
position (point-max)
|
position (point-max)
|
||||||
buffer-file-coding-system t)))))
|
buffer-file-coding-system t)))))
|
||||||
(cond ((not adjust-end) (not (zerop diff)))
|
(cond (strict (not (zerop diff)))
|
||||||
(vlf-partial-decode-shown
|
(vlf-partial-decode-shown
|
||||||
(or (< diff -3) (< 0 diff)))
|
(or (< diff -3) (< 0 diff)))
|
||||||
(t (or (< diff 0) (< 3 diff))))))
|
(t (or (< diff 0) (< 3 diff))))))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user