mirror of
				https://github.com/m00natic/vlfi.git
				synced 2025-10-30 22:53:37 +00:00 
			
		
		
		
	Prevent inserting of too small file regions for GNU Emacs later than
24.3.
This commit is contained in:
		
							
								
								
									
										35
									
								
								vlf.el
									
									
									
									
									
								
							
							
						
						
									
										35
									
								
								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) | ||||||
|                  (vlf-with-undo-disabled |                  (if (and (not vlf-partial-decode-shown) | ||||||
|                   (setq shift-end (cdr (vlf-insert-file-contents |                           (< (- end vlf-end-pos) 4)) | ||||||
|                                         vlf-end-pos end nil t |                      (setq end vlf-end-pos) | ||||||
|                                         (point-max))))))) |                    (vlf-with-undo-disabled | ||||||
|  |                     (setq shift-end (cdr (vlf-insert-file-contents | ||||||
|  |                                           vlf-end-pos end nil t | ||||||
|  |                                           (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) | ||||||
|                  (let ((edit-end-pos (point-max))) |                  (if (and (not vlf-partial-decode-shown) | ||||||
|                    (vlf-with-undo-disabled |                           (< (- vlf-start-pos start) 4)) | ||||||
|                     (setq shift-start (car (vlf-insert-file-contents |                      (setq start vlf-start-pos) | ||||||
|                                             start vlf-start-pos |                    (let ((edit-end-pos (point-max))) | ||||||
|                                             t nil edit-end-pos))) |                      (vlf-with-undo-disabled | ||||||
|                     (goto-char (point-min)) |                       (setq shift-start (car (vlf-insert-file-contents | ||||||
|                     (insert (delete-and-extract-region edit-end-pos |                                               start vlf-start-pos | ||||||
|                                                        (point-max))))))) |                                               t nil edit-end-pos))) | ||||||
|  |                       (goto-char (point-min)) | ||||||
|  |                       (insert (delete-and-extract-region | ||||||
|  |                                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)))))) | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user