diff --git a/hphp/hack/Makefile.dune b/hphp/hack/Makefile.dune index 929c4ca9b1b51..d092120c4a52e 100644 --- a/hphp/hack/Makefile.dune +++ b/hphp/hack/Makefile.dune @@ -35,6 +35,7 @@ build-hack$(2): dune build \ src/hh_server.$(1) \ src/hh_client.$(1) \ + src/hh_single_ide_format.$(1) \ src/hh_single_type_check.$(1) \ src/hackfmt.$(1) \ src/hh_parse.$(1) \ @@ -44,6 +45,7 @@ copy-hack$(2)-files: build-hack$(2) mkdir -p "$(HACK_BIN_DIR)" ${COPY_EXE} "$(DUNE_BUILD_DIR)/default/hack/src/hh_server.$(1)" "$(HACK_BIN_DIR)/hh_server$(ext)" ${COPY_EXE} "$(DUNE_BUILD_DIR)/default/hack/src/hh_client.$(1)" "$(HACK_BIN_DIR)/hh_client$(ext)" + ${COPY_EXE} "$(DUNE_BUILD_DIR)/default/hack/src/hh_single_ide_format.$(1)" "$(HACK_BIN_DIR)/hh_single_ide_format$(ext)" ${COPY_EXE} "$(DUNE_BUILD_DIR)/default/hack/src/hh_single_type_check.$(1)" "$(HACK_BIN_DIR)/hh_single_type_check$(ext)" ${COPY_EXE} "$(DUNE_BUILD_DIR)/default/hack/src/hackfmt.$(1)" "$(HACK_BIN_DIR)/hackfmt$(ext)" ${COPY_EXE} "$(DUNE_BUILD_DIR)/default/hack/src/hh_parse.$(1)" "$(HACK_BIN_DIR)/hh_parse$(ext)" diff --git a/hphp/hack/src/client/ide_service/ide_format.ml b/hphp/hack/src/client/ide_service/ide_format.ml index bd8c0b7b4f094..0ca75dbc52943 100644 --- a/hphp/hack/src/client/ide_service/ide_format.ml +++ b/hphp/hack/src/client/ide_service/ide_format.ml @@ -179,7 +179,7 @@ let minimal_edit (old_src : string) (new_src : string) : (List.length old_src_lines - range_end_line) in let (new_text, start_line_adjustment) = - if List.is_empty new_src_novel_lines then + if List.is_empty new_src_novel_lines && range_end_line < List.length new_src_lines then (* Empty `new_src_novel_lines` does not mean that there was no change (otherwise we wouldn't have reached here), diff --git a/hphp/hack/test/hackfmt/ide_format/newlines3.php b/hphp/hack/test/hackfmt/ide_format/newlines3.php new file mode 100644 index 0000000000000..17a00cd099293 --- /dev/null +++ b/hphp/hack/test/hackfmt/ide_format/newlines3.php @@ -0,0 +1,10 @@ + lines and columns in ranges are 1-indexed +received code: +1