88using SharpDenizenTools . MetaHandlers ;
99using SharpDenizenTools . MetaObjects ;
1010using FreneticUtilities . FreneticToolkit ;
11- using YamlDotNet . Core ;
12- using YamlDotNet . Core . Tokens ;
13- using System . ComponentModel ;
14- using static SharpDenizenTools . MetaHandlers . SingleTag ;
1511
1612namespace SharpDenizenTools . ScriptAnalysis
1713{
@@ -322,7 +318,28 @@ public void BasicLineFormatCheck()
322318 endChar = Math . Max ( 0 , endChar ) ;
323319 Warn ( MinorWarnings , i , "stray_space_eol" , "Stray space after end of line (possible copy/paste mixup. Enable View->Render Whitespace in VS Code)." , endChar , Math . Max ( endChar , line . Length - 1 ) ) ;
324320 }
325- else if ( CleanedLines [ i ] . Length > 0 && ! CleanedLines [ i ] . StartsWith ( "-" ) && ! CleanedLines [ i ] . Contains ( ':' ) )
321+ else if ( CleanedLines [ i ] . StartsWith ( "- " ) )
322+ {
323+ int spaces = CountPreSpaces ( line ) ;
324+ while ( i + 1 < Lines . Length )
325+ {
326+ string line2 = Lines [ i + 1 ] . Replace ( "\t " , " " ) ;
327+ string cleaned2 = CleanedLines [ i + 1 ] ;
328+ if ( CountPreSpaces ( line2 ) > spaces && ! cleaned2 . StartsWith ( "- " ) )
329+ {
330+ i ++ ;
331+ if ( cleaned2 . EndsWith ( ':' ) )
332+ {
333+ break ;
334+ }
335+ }
336+ else
337+ {
338+ break ;
339+ }
340+ }
341+ }
342+ else if ( CleanedLines [ i ] . Length > 0 && ! CleanedLines [ i ] . Contains ( ':' ) )
326343 {
327344 Warn ( Warnings , i , "useless_invalid_line" , "Useless/invalid line (possibly missing a `-` or a `:`, or just accidentally hit enter or paste)." , Lines [ i ] . IndexOf ( CleanedLines [ i ] [ 0 ] ) , Lines [ i ] . Length - 1 ) ;
328345 }
@@ -475,14 +492,14 @@ void warnPart(SingleTag.Part part, string key, string message)
475492 tracer . Trace ( ) ;
476493 if ( SurroundingWorkspace is not null )
477494 {
478- foreach ( Part part in parsed . Parts )
495+ foreach ( SingleTag . Part part in parsed . Parts )
479496 {
480497 if ( part . PossibleTags . Count == 1 )
481498 {
482499 MetaTag actualTag = part . PossibleTags [ 0 ] ;
483500 if ( actualTag . ParsedFormat . Parts . Count <= 2 && part . Parameter is not null && part . Parameter . Length > 0 )
484501 {
485- Part metaPart = actualTag . ParsedFormat . Parts [ ^ 1 ] ;
502+ SingleTag . Part metaPart = actualTag . ParsedFormat . Parts [ ^ 1 ] ;
486503 if ( metaPart . Parameter is not null && metaPart . Parameter . StartsWithFast ( '<' ) )
487504 {
488505 string input = part . Parameter . Before ( '[' ) . ToLowerFast ( ) ;
@@ -498,7 +515,7 @@ void warnPart(SingleTag.Part part, string key, string message)
498515 }
499516
500517 /// <summary>Helper to check a single tag parameter.</summary>
501- public void CheckTagParam ( Part part , Part metaPart , string input , Action < SingleTag . Part , string , string > warnPart )
518+ public void CheckTagParam ( SingleTag . Part part , SingleTag . Part metaPart , string input , Action < SingleTag . Part , string , string > warnPart )
502519 {
503520 switch ( metaPart . Parameter )
504521 {
@@ -638,7 +655,7 @@ public static CommandArgument[] BuildArgs(int line, int startChar, string string
638655 for ( int i = 0 ; i < len ; i ++ )
639656 {
640657 char c = stringArgs [ i ] ;
641- if ( c == ' ' && currentQuote == '\0 ' && inTagParams == 0 && ! currentTagHasFallback )
658+ if ( c == ' ' && currentQuote == '\0 ' && inTags == 0 && ! currentTagHasFallback )
642659 {
643660 if ( i > start )
644661 {
@@ -1481,11 +1498,30 @@ public Dictionary<LineTrackedString, object> GatherActualContainers()
14811498 pspaces = spaces ;
14821499 continue ;
14831500 }
1484- if ( cleaned . EndsWith ( ":" ) )
1501+ string text = cleaned [ "- " . Length ..] ;
1502+ while ( i + 1 < Lines . Length )
1503+ {
1504+ string line2 = Lines [ i + 1 ] . Replace ( "\t " , " " ) ;
1505+ string cleaned2 = CleanedLines [ i + 1 ] ;
1506+ if ( CountPreSpaces ( line2 ) > spaces && ! cleaned2 . StartsWith ( "- " ) )
1507+ {
1508+ text += "\n " + line2 ;
1509+ i ++ ;
1510+ if ( cleaned2 . EndsWith ( ':' ) )
1511+ {
1512+ break ;
1513+ }
1514+ }
1515+ else
1516+ {
1517+ break ;
1518+ }
1519+ }
1520+ if ( text . EndsWith ( ':' ) )
14851521 {
1486- if ( cleaned . StartsWith ( "- definemap " ) )
1522+ if ( text . StartsWith ( "definemap " ) )
14871523 {
1488- clist . Add ( new LineTrackedString ( i , cleaned [ "- " . Length .. ] , cleanStartCut + 2 ) ) ;
1524+ clist . Add ( new LineTrackedString ( i , text , cleanStartCut + 2 ) ) ;
14891525 while ( i + 1 < Lines . Length )
14901526 {
14911527 string subLine = Lines [ i + 1 ] . Replace ( "\t " , " " ) ;
@@ -1501,13 +1537,13 @@ public Dictionary<LineTrackedString, object> GatherActualContainers()
15011537 }
15021538 else
15031539 {
1504- secwaiting = new LineTrackedString ( i , cleaned . Substring ( "- " . Length , cleaned . Length - "- :" . Length ) , cleanStartCut + 2 ) ;
1540+ secwaiting = new LineTrackedString ( i , text [ .. ^ 1 ] , cleanStartCut + 2 ) ;
15051541 buildingSubList = true ;
15061542 }
15071543 }
15081544 else
15091545 {
1510- clist . Add ( new LineTrackedString ( i , cleaned [ "- " . Length .. ] , cleanStartCut + 2 ) ) ;
1546+ clist . Add ( new LineTrackedString ( i , text , cleanStartCut + 2 ) ) ;
15111547 }
15121548 pspaces = spaces ;
15131549 continue ;
0 commit comments