@@ -431,18 +431,27 @@ const taskTimerStateField = StateField.define<DecorationSet>({
431431 * Create task timer decorations for the current state
432432 */
433433function createTaskTimerDecorations ( state : EditorState ) : DecorationSet {
434+ console . log ( "[TaskTimer] Creating decorations, timerConfig:" , timerConfig ) ;
435+
434436 if ( ! timerConfig ?. settings ?. enabled ) {
437+ console . log ( "[TaskTimer] Timer not enabled or no config" ) ;
435438 return Decoration . none ;
436439 }
437440
438441 // Get editor info to access app and file information
439442 const editorInfo = state . field ( editorInfoField ) ;
440443 if ( ! editorInfo ?. app ) {
444+ console . log ( "[TaskTimer] No editor info or app" ) ;
441445 return Decoration . none ;
442446 }
443447
444448 const file = editorInfo . app . workspace . getActiveFile ( ) ;
445- if ( ! file ) return Decoration . none ;
449+ if ( ! file ) {
450+ console . log ( "[TaskTimer] No active file" ) ;
451+ return Decoration . none ;
452+ }
453+
454+ console . log ( "[TaskTimer] Processing file:" , file . path ) ;
446455
447456 const metadataDetector = new TaskTimerMetadataDetector (
448457 editorInfo . app ,
@@ -451,20 +460,27 @@ function createTaskTimerDecorations(state: EditorState): DecorationSet {
451460 ) ;
452461
453462 if ( ! metadataDetector . isTimerEnabledForFile ( file ) ) {
463+ console . log ( "[TaskTimer] Timer not enabled for file:" , file . path ) ;
454464 return Decoration . none ;
455465 }
456466
467+ console . log ( "[TaskTimer] Timer enabled for file, processing..." ) ;
468+
457469 const timerManager = new TaskTimerManager ( timerConfig . settings ) ;
458470 const decorations : Range < Decoration > [ ] = [ ] ;
459471 const doc = state . doc ;
460472
473+ console . log ( "[TaskTimer] Document has" , doc . lines , "lines" ) ;
474+
461475 // Process all lines in the document
462476 for ( let i = 1 ; i <= doc . lines ; i ++ ) {
463477 const line = doc . line ( i ) ;
464478 const lineText = line . text ;
465479
466480 // Check if this line contains a task
467481 if ( isTaskLine ( lineText ) ) {
482+ console . log ( "[TaskTimer] Found task line:" , lineText . trim ( ) ) ;
483+
468484 // Use existing folding logic to check if this is a parent task
469485 const range = calculateRangeForTransform ( state , {
470486 from : line . from ,
@@ -476,6 +492,7 @@ function createTaskTimerDecorations(state: EditorState): DecorationSet {
476492 range . to > line . to &&
477493 hasSubTasks ( doc . sliceString ( range . from , range . to ) , lineText )
478494 ) {
495+ console . log ( "[TaskTimer] Found parent task with subtasks" ) ;
479496 // Extract existing block reference if present
480497 const existingBlockId = extractBlockRef ( lineText ) ;
481498
@@ -496,10 +513,12 @@ function createTaskTimerDecorations(state: EditorState): DecorationSet {
496513
497514 // Add decoration at the start of the line
498515 decorations . push ( timerDeco . range ( line . from ) ) ;
516+ console . log ( "[TaskTimer] Added timer decoration for line:" , i ) ;
499517 }
500518 }
501519 }
502520
521+ console . log ( "[TaskTimer] Created" , decorations . length , "timer decorations" ) ;
503522 return Decoration . set ( decorations , true ) ;
504523}
505524
@@ -571,10 +590,11 @@ export function taskTimerExtension(
571590 settings : TaskTimerSettings ,
572591 metadataCache : MetadataCache
573592) {
574- // Set global references for StateField access
575- globalApp = app ;
576- globalSettings = settings ;
577- globalMetadataCache = metadataCache ;
593+ // Set global configuration for StateField access
594+ timerConfig = {
595+ settings,
596+ metadataCache
597+ } ;
578598
579599 return [ taskTimerStateField ] ;
580600}
0 commit comments