@@ -7,6 +7,8 @@ const MOCK_SETTINGS = {
77 todoFilename : "TODO.md" ,
88 excludeFilePattern : "<!-- exclude TODO -->" ,
99 excludeFolderFilename : ".exclude_todos" ,
10+ excludeRegionBegin : "%% exclude: start %%" ,
11+ excludeRegionEnd : "%% exclude: end %%" ,
1012 useFullFilepath : false ,
1113 includeNotStarted : true ,
1214 includeInProgress : true ,
@@ -380,6 +382,76 @@ describe("TodoService", () => {
380382 expect ( actual ) . toEqual ( expected ) ;
381383 } ) ;
382384
385+ test ( "parseTodos excludes task items inside exclude regions" , ( ) => {
386+ // Arrange
387+ const content = `- [ ] Included
388+ %% exclude: start %%
389+ - [ ] Excluded
390+ - [.] Also excluded
391+ %% exclude: end %%
392+ - [ ] Also included` ;
393+
394+ const mockFileService = new MockFileService ( [ ] ) ;
395+
396+ // Act
397+ const todoService = new TodoService ( mockFileService , MOCK_SETTINGS ) ;
398+ const actual = todoService . parseTodos ( content ) ;
399+
400+ // Assert
401+ expect ( actual ) . toEqual ( [
402+ {
403+ task : TaskType . NotStarted ,
404+ text : "Included" ,
405+ indentation : "" ,
406+ lineno : 0 ,
407+ } as Todo ,
408+ {
409+ task : TaskType . NotStarted ,
410+ text : "Also included" ,
411+ indentation : "" ,
412+ lineno : 5 ,
413+ } as Todo ,
414+ ] ) ;
415+ } ) ;
416+
417+ test ( "parseTodos handles multiple exclude regions" , ( ) => {
418+ // Arrange
419+ const content = `- [ ] First
420+ %% exclude: start %%
421+ - [ ] Excluded 1
422+ %% exclude: end %%
423+ - [ ] Second
424+ %% exclude: start %%
425+ - [ ] Excluded 2
426+ %% exclude: end %%
427+ - [ ] Third` ;
428+
429+ const mockFileService = new MockFileService ( [ ] ) ;
430+
431+ // Act
432+ const todoService = new TodoService ( mockFileService , MOCK_SETTINGS ) ;
433+ const actual = todoService . parseTodos ( content ) ;
434+
435+ // Assert
436+ expect ( actual . map ( ( t ) => t . text ) ) . toEqual ( [ "First" , "Second" , "Third" ] ) ;
437+ } ) ;
438+
439+ test ( "parseTodos excludes to end of file when region is not closed" , ( ) => {
440+ // Arrange
441+ const content = `- [ ] Included
442+ %% exclude: start %%
443+ - [ ] Excluded` ;
444+
445+ const mockFileService = new MockFileService ( [ ] ) ;
446+
447+ // Act
448+ const todoService = new TodoService ( mockFileService , MOCK_SETTINGS ) ;
449+ const actual = todoService . parseTodos ( content ) ;
450+
451+ // Assert
452+ expect ( actual . map ( ( t ) => t . text ) ) . toEqual ( [ "Included" ] ) ;
453+ } ) ;
454+
383455 test ( "Whole shebang formats TODO.md correctly with task items nested under normal lists" , async ( ) => {
384456 // Arrange
385457 const taskFile = createMockFile (
0 commit comments