Skip to content

Commit

Permalink
newline for todo.txt
Browse files Browse the repository at this point in the history
  • Loading branch information
harshad1 committed Mar 7, 2024
1 parent 72a8494 commit a772e36
Showing 1 changed file with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,8 @@ private void appendToExistingDocumentAndClose(final File file, final boolean sho

final String oldContent = document.loadContent(context);
if (oldContent != null) {
final String newContent = oldContent + "\n" + formatted;
final String nline = oldContent.endsWith("\n") ? "" : "\n";
final String newContent = oldContent + nline + formatted;
document.saveContent(context, newContent);
} else {
Toast.makeText(context, R.string.error_could_not_open_file, Toast.LENGTH_LONG).show();
Expand Down Expand Up @@ -287,7 +288,7 @@ private String getFormatted(final boolean asLink, final File src, final int form
formatted = formatShare(formatted);

if (format == FormatRegistry.FORMAT_TODOTXT) {
formatted = TodoTxtTask.getToday() + " " + formatted.replaceAll("\\n", " ");
formatted = "\\n" + TodoTxtTask.getToday() + " " + formatted.replaceAll("\\n", " ");
}

return formatted;
Expand Down

0 comments on commit a772e36

Please sign in to comment.