瀏覽代碼

fix bug in indented wrapped results insertion
* lisp/ob.el (org-babel-insert-result): Fix bug in indented wrapped
results insertion.
* testing/lisp/test-ob.el (test-ob/org-babel-results-indented-wrap):
Test correct indentation behavior.

Eric Schulte 13 年之前
父節點
當前提交
dbe4bf805f
共有 2 個文件被更改,包括 15 次插入1 次删除
  1. 2 1
      lisp/ob.el
  2. 13 0
      testing/lisp/test-ob.el

+ 2 - 1
lisp/ob.el

@@ -1838,7 +1838,8 @@ code ---- the results are extracted in the syntax of the source
 	(flet ((wrap (start finish)
 		     (goto-char end) (insert (concat finish "\n"))
 		     (goto-char beg) (insert (concat start "\n"))
-		     (goto-char end) (setq end (point-marker)))
+		     (goto-char end) (goto-char (point-at-eol))
+		     (setq end (point-marker)))
 	       (proper-list-p (it) (and (listp it) (null (cdr (last it))))))
 	  ;; insert results based on type
 	  (cond

+ 13 - 0
testing/lisp/test-ob.el

@@ -699,6 +699,19 @@ replacement happens correctly."
 
 * next heading"))
 
+(ert-deftest test-ob/org-babel-results-indented-wrap ()
+  "Ensure that wrapped results are inserted correction when indented.
+If not inserted correctly then the second evaluation will fail
+trying to find the :END: marker."
+  (org-test-with-temp-text
+   "- indented
+  #+begin_src sh :results file wrap
+    echo test.txt
+  #+end_src"
+    (org-babel-next-src-block 1)
+    (org-babel-execute-src-block)
+    (org-babel-execute-src-block)))
+
 (ert-deftest test-ob/org-babel-remove-result--results-wrap ()
   "Test `org-babel-remove-result' with :results wrap."
   (test-ob-verify-result-and-removed-result