File tree Expand file tree Collapse file tree 1 file changed +92
-0
lines changed Expand file tree Collapse file tree 1 file changed +92
-0
lines changed Original file line number Diff line number Diff line change @@ -887,6 +887,98 @@ struct A {
887887"
888888 ))
889889
890+ ; ; When point is inside an example code block, indent-for-tab-command
891+ ; ; should reindent the example code.
892+ (ert-deftest indent-inside-doc-example ()
893+ (rust-test-manip-code
894+ "
895+ /// ```
896+ /// if 2 + 2 == 4 {
897+ /// success();
898+ /// }
899+ /// ```
900+ "
901+ 34
902+ #'indent-for-tab-command
903+ "
904+ /// ```
905+ /// if 2 + 2 == 4 {
906+ /// success();
907+ /// }
908+ /// ```
909+ "
910+ 38 ))
911+
912+ ; ; Inside example code blocks, hidden lines starting with "# " should
913+ ; ; be indented as if the "# " wasn't there.
914+ (ert-deftest indent-inside-doc-example-hidden-code ()
915+ (rust-test-manip-code
916+ "
917+ /// ```
918+ /// # if 2 + 2 == 4 {
919+ /// # success();
920+ /// # }
921+ /// ```
922+ "
923+ 36
924+ #'indent-for-tab-command
925+ "
926+ /// ```
927+ /// # if 2 + 2 == 4 {
928+ /// # success();
929+ /// # }
930+ /// ```
931+ "
932+ 42 ))
933+
934+ ; ; Inside example code blocks, hidden lines starting with "# "
935+ ; ; shouldn't affect indentation of non-hidden lines.
936+ (ert-deftest indent-inside-doc-example-with-hidden-block ()
937+ (rust-test-manip-code
938+ "
939+ /// ```
940+ /// # if 2 + 2 == 4 {
941+ /// success();
942+ /// # }
943+ /// ```
944+ "
945+ 40
946+ #'indent-for-tab-command
947+ "
948+ /// ```
949+ /// # if 2 + 2 == 4 {
950+ /// success();
951+ /// # }
952+ /// ```
953+ "
954+ 36 ))
955+
956+ ; ; When point is outside the comment, indent-for-tab-command should
957+ ; ; reindent the comment line without affecting its contents.
958+ (ert-deftest indent-outside-doc-example ()
959+ (rust-test-manip-code
960+ "
961+ impl Foo {
962+ /// ```
963+ /// if 2 + 2 == 4 {
964+ /// success();
965+ /// }
966+ /// ```
967+ }
968+ "
969+ 49
970+ #'indent-for-tab-command
971+ "
972+ impl Foo {
973+ /// ```
974+ /// if 2 + 2 == 4 {
975+ /// success();
976+ /// }
977+ /// ```
978+ }
979+ "
980+ 53 ))
981+
890982(defconst rust-test-motion-string
891983 "
892984fn fn1(arg: i32) -> bool {
You can’t perform that action at this time.
0 commit comments