@@ -524,95 +524,85 @@ export class CaptureChoiceBuilder extends ChoiceBuilder {
524524 }
525525
526526 const inlineEnabled = ! ! this . choice . insertAfter ?. inline ;
527- const inlineDisabledDesc =
528- "Inline insertion targets text, not sections/lines." ;
529527
530- const insertAtEndSetting : Setting = new Setting ( this . contentEl ) ;
531- insertAtEndSetting
532- . setName ( "Insert at end of section" )
533- . setDesc (
534- inlineEnabled
535- ? inlineDisabledDesc
536- : "Place the text at the end of the matched section instead of the top." ,
537- )
538- . addToggle ( ( toggle ) =>
539- toggle
540- . setValue ( this . choice . insertAfter ?. insertAtEnd )
541- . onChange ( ( value ) => {
542- this . choice . insertAfter . insertAtEnd = value ;
543- this . reload ( ) ;
544- } ) ,
545- ) ;
546- insertAtEndSetting . setDisabled ( inlineEnabled ) ;
528+ if ( ! inlineEnabled ) {
529+ const insertAtEndSetting : Setting = new Setting ( this . contentEl ) ;
530+ insertAtEndSetting
531+ . setName ( "Insert at end of section" )
532+ . setDesc (
533+ "Place the text at the end of the matched section instead of the top." ,
534+ )
535+ . addToggle ( ( toggle ) =>
536+ toggle
537+ . setValue ( this . choice . insertAfter ?. insertAtEnd )
538+ . onChange ( ( value ) => {
539+ this . choice . insertAfter . insertAtEnd = value ;
540+ this . reload ( ) ;
541+ } ) ,
542+ ) ;
547543
548- if ( ! this . choice . insertAfter ?. blankLineAfterMatchMode ) {
549- this . choice . insertAfter . blankLineAfterMatchMode = "auto" ;
550- }
544+ if ( ! this . choice . insertAfter ?. blankLineAfterMatchMode ) {
545+ this . choice . insertAfter . blankLineAfterMatchMode = "auto" ;
546+ }
551547
552- const blankLineModeDesc =
553- "Controls whether Insert After skips existing blank lines after the matched line." ;
554- const insertAtEndEnabled = ! ! this . choice . insertAfter ?. insertAtEnd ;
555- const blankLineModeDisabled = inlineEnabled || insertAtEndEnabled ;
556- const blankLineModeSetting : Setting = new Setting ( this . contentEl ) ;
557- blankLineModeSetting
558- . setName ( "Blank lines after match" )
559- . setDesc (
560- inlineEnabled
561- ? inlineDisabledDesc
562- : insertAtEndEnabled
548+ const blankLineModeDesc =
549+ "Controls whether Insert After skips existing blank lines after the matched line." ;
550+ const insertAtEndEnabled = ! ! this . choice . insertAfter ?. insertAtEnd ;
551+ const blankLineModeSetting : Setting = new Setting ( this . contentEl ) ;
552+ blankLineModeSetting
553+ . setName ( "Blank lines after match" )
554+ . setDesc (
555+ insertAtEndEnabled
563556 ? "Not used when inserting at end of section."
564557 : blankLineModeDesc ,
565- )
566- . addDropdown ( ( dropdown ) => {
567- dropdown
568- . addOption ( "auto" , "Auto (headings only)" )
569- . addOption ( "skip" , "Always skip" )
570- . addOption ( "none" , "Never skip" )
571- . setValue (
572- this . choice . insertAfter ?. blankLineAfterMatchMode ?? "auto" ,
573- )
574- . onChange ( ( value ) => {
575- this . choice . insertAfter . blankLineAfterMatchMode = value as
576- | "auto"
577- | "skip"
578- | "none" ;
579- } ) ;
580- dropdown . setDisabled ( blankLineModeDisabled ) ;
581- } ) ;
582- blankLineModeSetting . setDisabled ( blankLineModeDisabled ) ;
583-
584- const considerSubsectionsSetting : Setting = new Setting ( this . contentEl ) ;
585- considerSubsectionsSetting
586- . setName ( "Consider subsections" )
587- . setDesc (
588- inlineEnabled
589- ? inlineDisabledDesc
590- : "Also include the section’s subsections (requires target to be a heading starting with #). Subsections are headings inside the section." ,
591- )
592- . addToggle ( ( toggle ) =>
593- toggle
594- . setValue ( this . choice . insertAfter ?. considerSubsections )
595- . onChange ( ( value ) => {
596- if ( ! value ) {
597- this . choice . insertAfter . considerSubsections = false ;
598- return ;
599- }
558+ )
559+ . addDropdown ( ( dropdown ) => {
560+ dropdown
561+ . addOption ( "auto" , "Auto (headings only)" )
562+ . addOption ( "skip" , "Always skip" )
563+ . addOption ( "none" , "Never skip" )
564+ . setValue (
565+ this . choice . insertAfter ?. blankLineAfterMatchMode ?? "auto" ,
566+ )
567+ . onChange ( ( value ) => {
568+ this . choice . insertAfter . blankLineAfterMatchMode = value as
569+ | "auto"
570+ | "skip"
571+ | "none" ;
572+ } ) ;
573+ dropdown . setDisabled ( insertAtEndEnabled ) ;
574+ } ) ;
575+ blankLineModeSetting . setDisabled ( insertAtEndEnabled ) ;
600576
601- const targetIsHeading =
602- this . choice . insertAfter . after . startsWith ( "#" ) ;
603- if ( targetIsHeading ) {
604- this . choice . insertAfter . considerSubsections = value ;
605- } else {
606- this . choice . insertAfter . considerSubsections = false ;
607- // reset the toggle to match state and inform user
608- toggle . setValue ( false ) ;
609- new Notice (
610- "Consider subsections requires the target to be a heading (starts with #)" ,
611- ) ;
612- }
613- } ) ,
614- ) ;
615- considerSubsectionsSetting . setDisabled ( inlineEnabled ) ;
577+ new Setting ( this . contentEl )
578+ . setName ( "Consider subsections" )
579+ . setDesc (
580+ "Also include the section’s subsections (requires target to be a heading starting with #). Subsections are headings inside the section." ,
581+ )
582+ . addToggle ( ( toggle ) =>
583+ toggle
584+ . setValue ( this . choice . insertAfter ?. considerSubsections )
585+ . onChange ( ( value ) => {
586+ if ( ! value ) {
587+ this . choice . insertAfter . considerSubsections = false ;
588+ return ;
589+ }
590+
591+ const targetIsHeading =
592+ this . choice . insertAfter . after . startsWith ( "#" ) ;
593+ if ( targetIsHeading ) {
594+ this . choice . insertAfter . considerSubsections = value ;
595+ } else {
596+ this . choice . insertAfter . considerSubsections = false ;
597+ // reset the toggle to match state and inform user
598+ toggle . setValue ( false ) ;
599+ new Notice (
600+ "Consider subsections requires the target to be a heading (starts with #)" ,
601+ ) ;
602+ }
603+ } ) ,
604+ ) ;
605+ }
616606
617607 const createLineIfNotFound : Setting = new Setting ( this . contentEl ) ;
618608 createLineIfNotFound
0 commit comments