You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
`User selection detected (${startSelection.from}-${startSelection.to}) covering replacement range (${fromA}-${toA}). Skipping automatic cycling as this is user-intended replacement.`
76
+
);
77
+
returnfalse;
78
+
}
79
+
80
+
// Get valid task status marks from plugin settings
81
+
const{ marks }=getTaskStatusConfig(plugin);
82
+
constvalidMarks=Object.values(marks);
83
+
84
+
// Check if both the original and inserted characters are valid task status marks
// If either character is not a valid task mark, this is likely manual input
89
+
if(!isOriginalValidMark||!isInsertedValidMark){
90
+
returnfalse;
91
+
}
92
+
93
+
// Check if the replacement position is at a task marker location
94
+
consttaskRegex=/^[\s|\t]*([-*+]|\d+\.)\s+\[(.)]/;
95
+
constmatch=newLineText.match(taskRegex);
96
+
97
+
if(!match){
98
+
returnfalse;
99
+
}
100
+
101
+
// Log successful validation for debugging
102
+
console.log(
103
+
`Valid task marker replacement detected. No user selection or selection doesn't cover replacement range. Original: '${originalText}' -> New: '${insertedText}' at position ${fromA}-${toA}`
104
+
);
105
+
106
+
returntrue;
107
+
}
108
+
41
109
/**
42
110
* Finds a task status change event in the transaction
43
111
* @param tr The transaction to check
44
112
* @param tasksPluginLoaded Whether the Obsidian Tasks plugin is loaded
113
+
* @param plugin The plugin instance (optional for backwards compatibility)
45
114
* @returns Information about all changed task statuses or empty array if no status was changed
46
115
*/
47
116
exportfunctionfindTaskStatusChanges(
48
117
tr: Transaction,
49
-
tasksPluginLoaded: boolean
118
+
tasksPluginLoaded: boolean,
119
+
plugin?: TaskProgressBarPlugin
50
120
): {
51
121
position: number;
52
122
currentMark: string;
@@ -257,15 +327,40 @@ export function findTaskStatusChanges(
257
327
pos===newLine.from+markIndex&&
258
328
insertedText!=="["
259
329
){
260
-
// NEW: Check if this is a replacement operation (user selected and replaced text)
261
-
// If fromA != toA, it means user deleted existing text and replaced it
262
-
// This indicates user has explicit intent for the specific character
263
-
// In this case, we should NOT trigger automatic cycling
330
+
// Check if this is a replacement operation and validate if it's a valid task marker replacement
0 commit comments