imdone-core 2.6.0 → 2.6.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## 2.6.1
2
+
3
+ - Preserve repeated and whitespace-only blank lines during Markdown/text task write-back when EOF task ending is enabled, including file-watcher transformations after an editor save. Default cleanup and code-file behavior are unchanged.
4
+
1
5
  ## 2.6.0
2
6
 
3
7
  - Add opt-in `settings.cards.endTaskAtEndOfFile` for Markdown/text tasks to retain blank lines through EOF, while preserving next-task and explicit termination boundaries. Existing blank-line behavior remains the default; code-file parsing is unchanged.
package/README.md CHANGED
@@ -93,6 +93,8 @@ settings:
93
93
 
94
94
  This ignores blank-line termination regardless of blank-line counts. A following task, custom text terminator, list boundary or explicit `</card>` still ends the task. Code-file parsing is unchanged. The setting defaults to `false`, preserving the existing two-blank-line behavior.
95
95
 
96
+ In 2.6.1 and newer, EOF mode also preserves repeated and whitespace-only blank lines during task write-back and file-watcher transformations.
97
+
96
98
  Imdone uses todo.txt +project/tag @context and meta:data
97
99
 
98
100
  #### Create date
package/lib/file.js CHANGED
@@ -899,8 +899,9 @@ export class File extends Emitter {
899
899
  }
900
900
 
901
901
  modifyTaskFromContent (task, content, config) {
902
- content = trimBlankLines(content, this.isCodeFile())
903
- task.updateFromContent(content)
902
+ const preserveBlankLines = config.endTaskAtEndOfFile && !this.isCodeFile()
903
+ if (!preserveBlankLines) content = trimBlankLines(content, this.isCodeFile())
904
+ task.updateFromContent(content, { preserveBlankLines })
904
905
  this.modifyTask(task, config)
905
906
  }
906
907
 
package/lib/task.js CHANGED
@@ -165,12 +165,11 @@ export class Task {
165
165
  this.content = this.text + lineEnd + this.descriptionString
166
166
  }
167
167
 
168
- updateFromContent(content) {
169
- // replace all occurrences of two empty lines in a row with a single empty line
170
- content = content.replace(/\n\s*\n\s*\n/g, '\n\n')
168
+ updateFromContent(content, { preserveBlankLines = false } = {}) {
169
+ if (!preserveBlankLines) content = content.replace(/\n\s*\n\s*\n/g, '\n\n')
171
170
  let lines = eol.split(content)
172
171
  this.text = lines.shift().trimStart()
173
- if (lines && lines.length > 1 && lines[lines.length - 1].trim() === '') lines.pop()
172
+ if (!preserveBlankLines && lines.length > 1 && lines[lines.length - 1].trim() === '') lines.pop()
174
173
  this.description = lines
175
174
  this.parse()
176
175
  }
@@ -913,4 +912,4 @@ export class Task {
913
912
  task.getId() == this.getId()
914
913
  )
915
914
  }
916
- }
915
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "imdone-core",
3
- "version": "2.6.0",
3
+ "version": "2.6.1",
4
4
  "description": "imdone-core",
5
5
  "repository": {
6
6
  "type": "git",
package/types/card.d.ts CHANGED
@@ -151,7 +151,9 @@ export function newCard(task: any, _project: any, dontParse: any): {
151
151
  };
152
152
  getContent(): any;
153
153
  updateContent(): void;
154
- updateFromContent(content: any): void;
154
+ updateFromContent(content: any, { preserveBlankLines }?: {
155
+ preserveBlankLines?: boolean | undefined;
156
+ }): void;
155
157
  toJSON(): /*elided*/ any & {
156
158
  allTags: any;
157
159
  allContext: any;
package/types/file.d.ts CHANGED
@@ -249,7 +249,9 @@ export class File extends Emitter<[never]> {
249
249
  };
250
250
  getContent(): any;
251
251
  updateContent(): void;
252
- updateFromContent(content: any): void;
252
+ updateFromContent(content: any, { preserveBlankLines }?: {
253
+ preserveBlankLines?: boolean | undefined;
254
+ }): void;
253
255
  toJSON(): /*elided*/ any & {
254
256
  allTags: any;
255
257
  allContext: any;
package/types/task.d.ts CHANGED
@@ -128,7 +128,9 @@ export class Task {
128
128
  };
129
129
  getContent(): any;
130
130
  updateContent(): void;
131
- updateFromContent(content: any): void;
131
+ updateFromContent(content: any, { preserveBlankLines }?: {
132
+ preserveBlankLines?: boolean | undefined;
133
+ }): void;
132
134
  toJSON(): this & {
133
135
  allTags: any;
134
136
  allContext: any;