@@ -153,6 +153,17 @@ export class CaptureChoiceEngine extends QuickAddChoiceEngine {
153153 canvasTarget ?. kind === "file"
154154 ? canvasTarget . targetFile . path
155155 : await this . getFormattedPathToCaptureTo ( this . choice . captureToActiveFile ) ;
156+
157+ if (
158+ ! canvasTarget &&
159+ ! this . choice . captureToActiveFile &&
160+ CANVAS_FILE_EXTENSION_REGEX . test ( filePath )
161+ ) {
162+ throw new ChoiceAbortError (
163+ "Capture to a .canvas file requires a target canvas node id." ,
164+ ) ;
165+ }
166+
156167 const content = this . getCaptureContent ( ) ;
157168
158169 type GetFileAndAddContentFn = (
@@ -324,30 +335,19 @@ export class CaptureChoiceEngine extends QuickAddChoiceEngine {
324335 }
325336
326337 const rawCaptureTo = this . choice . captureTo ?. trim ( ) ?? "" ;
327- if ( ! rawCaptureTo ) {
338+ const nodeId = this . choice . captureToCanvasNodeId ?. trim ( ) ?? "" ;
339+
340+ if ( ! rawCaptureTo || ! nodeId ) {
328341 return null ;
329342 }
330343
331344 const targetPath = await this . formatFilePath ( rawCaptureTo ) ;
332- const isCanvasTarget = CANVAS_FILE_EXTENSION_REGEX . test ( targetPath ) ;
333- const nodeId = this . choice . captureToCanvasNodeId ?. trim ( ) ?? "" ;
334-
335- if ( ! isCanvasTarget ) {
336- if ( ! nodeId ) {
337- return null ;
338- }
339-
345+ if ( ! CANVAS_FILE_EXTENSION_REGEX . test ( targetPath ) ) {
340346 throw new ChoiceAbortError (
341347 "Canvas node capture requires the target path to resolve to a .canvas file." ,
342348 ) ;
343349 }
344350
345- if ( ! nodeId ) {
346- throw new ChoiceAbortError (
347- "Canvas node capture requires a target canvas node id." ,
348- ) ;
349- }
350-
351351 return await resolveConfiguredCanvasCaptureTarget (
352352 this . app ,
353353 targetPath ,
0 commit comments