()
| 218 | const openedSourceFilePaths = new Set<string>(); |
| 219 | if (initialSingleFileSourcePath) openedSourceFilePaths.add(initialSingleFileSourcePath); |
| 220 | const getPrimarySource = () => { |
| 221 | if (mode === "annotate-last") { |
| 222 | return { plan: markdown, sourceSave: disabledSourceSave("message-mode") }; |
| 223 | } |
| 224 | if (mode === "annotate-folder") { |
| 225 | return { plan: markdown, sourceSave: disabledSourceSave("folder-mode") }; |
| 226 | } |
| 227 | if (renderHtml && rawHtml) { |
| 228 | return { plan: markdown, sourceSave: disabledSourceSave("html-render") }; |
| 229 | } |
| 230 | if (sourceConverted) { |
| 231 | return { plan: markdown, sourceSave: disabledSourceSave("converted-source") }; |
| 232 | } |
| 233 | if (/^https?:\/\//i.test(filePath)) { |
| 234 | return { plan: markdown, sourceSave: disabledSourceSave("not-local-file") }; |
| 235 | } |
| 236 | |
| 237 | const sourceSave = createSourceSaveCapability("single-file", initialSingleFileSourcePath ?? filePath); |
| 238 | if (!sourceSave.enabled) { |
| 239 | if (sourceSave.reason === "missing-file" && initialSingleFileSourcePath) { |
| 240 | const missingSourceSave = createSourceSaveCapabilityFromText("single-file", initialSingleFileSourcePath, markdown); |
| 241 | if (missingSourceSave.enabled) { |
| 242 | return { plan: markdown, sourceSave: missingSourceSave }; |
| 243 | } |
| 244 | } |
| 245 | return { plan: markdown, sourceSave }; |
| 246 | } |
| 247 | |
| 248 | try { |
| 249 | const snapshot = readSourceFileSnapshot(sourceSave.path); |
| 250 | return { |
| 251 | plan: snapshot.text, |
| 252 | sourceSave: { |
| 253 | ...sourceSave, |
| 254 | hash: snapshot.hash, |
| 255 | mtimeMs: snapshot.mtimeMs, |
| 256 | size: snapshot.size, |
| 257 | eol: snapshot.eol, |
| 258 | }, |
| 259 | }; |
| 260 | } catch { |
| 261 | return { plan: markdown, sourceSave: disabledSourceSave("unreadable-file") }; |
| 262 | } |
| 263 | }; |
| 264 | |
| 265 | const getReferenceRootPaths = () => getAnnotateReferenceRootPaths({ |
| 266 | mode, |
no test coverage detected