@@ -8,6 +8,7 @@ import {splitAllowedContext} from "@actions/workflow-parser/templates/allowed-co
88import { BasicExpressionToken } from "@actions/workflow-parser/templates/tokens/basic-expression-token" ;
99import { StringToken } from "@actions/workflow-parser/templates/tokens/string-token" ;
1010import { TemplateToken } from "@actions/workflow-parser/templates/tokens/template-token" ;
11+ import { MappingToken } from "@actions/workflow-parser/templates/tokens/mapping-token" ;
1112import { TokenRange } from "@actions/workflow-parser/templates/tokens/token-range" ;
1213import { File } from "@actions/workflow-parser/workflows/file" ;
1314import { FileProvider } from "@actions/workflow-parser/workflows/file-provider" ;
@@ -169,7 +170,8 @@ async function additionalValidations(
169170 // Validate action metadata (inputs, required fields) for regular steps
170171 if ( token . definition ?. key === "regular-step" && token . range ) {
171172 const context = getProviderContext ( documentUri , template , root , token . range ) ;
172- await validateActionReference ( diagnostics , token , context . step , config ) ;
173+ const indentSize = detectIndentSize ( root as MappingToken ) ;
174+ await validateActionReference ( diagnostics , token , context . step , config , indentSize ) ;
173175 }
174176
175177 // Validate job-level reusable workflow uses field format
@@ -823,4 +825,31 @@ function getStaticConcurrencyGroup(token: TemplateToken | undefined): StringToke
823825 return undefined ;
824826}
825827
828+ /**
829+ * Detects the indentation size used in the workflow file by examining the
830+ * difference between the "jobs" key column and its first child's column.
831+ */
832+ function detectIndentSize ( rootToken : MappingToken ) : number {
833+ // Find the "jobs" key in the root mapping to get its column position
834+ let jobsKeyColumn : number | undefined ;
835+ let jobsValue : TemplateToken | undefined ;
836+
837+ for ( const { key, value} of rootToken ) {
838+ if ( key . toString ( ) === "jobs" ) {
839+ jobsKeyColumn = key . range ?. start . column ;
840+ jobsValue = value ;
841+ break ;
842+ }
843+ }
844+
845+ if ( jobsKeyColumn !== undefined && jobsValue && isMapping ( jobsValue ) && jobsValue . count > 0 ) {
846+ const firstJob = jobsValue . get ( 0 ) ;
847+ if ( firstJob ?. key . range ) {
848+ return firstJob . key . range . start . column - jobsKeyColumn ;
849+ }
850+ }
851+
852+ return 2 ; // fallback
853+ }
854+
826855
0 commit comments