Make sure LIB_ID escape context allows for formatting constructs.

Also make sure that value field is updated from name changes when the
symbol is a power symbol (even if it's from the schematic instead of
the library).

Fixes https://gitlab.com/kicad/code/kicad/issues/11093

(cherry picked from commit a9eb7a0e28)
(cherry picked from commit 02252be29d)
This commit is contained in:
Jeff Young 2022-03-10 13:45:03 +00:00 committed by Seth Hillbrand
parent f058dc9ed8
commit 02b1f552fd
3 changed files with 14 additions and 4 deletions

View File

@ -142,7 +142,15 @@ bool ConvertSmartQuotesAndDashes( wxString* aString )
wxString EscapeString( const wxString& aSource, ESCAPE_CONTEXT aContext ) wxString EscapeString( const wxString& aSource, ESCAPE_CONTEXT aContext )
{ {
wxString converted; wxString converted;
std::vector<bool> braceStack; // true == formatting construct
auto hasFormattingPrefix =
[&]()
{
static wxString prefixes = wxT( "~_^" );
return !converted.IsEmpty() && prefixes.Find( converted.Last() ) >= 0;
};
converted.reserve( aSource.length() ); converted.reserve( aSource.length() );
@ -159,7 +167,7 @@ wxString EscapeString( const wxString& aSource, ESCAPE_CONTEXT aContext )
} }
else if( aContext == CTX_LIBID ) else if( aContext == CTX_LIBID )
{ {
if( c == '{' ) if( c == '{' && !hasFormattingPrefix() )
converted += wxT( "{brace}" ); converted += wxT( "{brace}" );
else if( c == '/' ) else if( c == '/' )
converted += wxT( "{slash}" ); converted += wxT( "{slash}" );
@ -227,7 +235,9 @@ wxString EscapeString( const wxString& aSource, ESCAPE_CONTEXT aContext )
converted += c; converted += c;
} }
else else
{
converted += c; converted += c;
}
} }
return converted; return converted;

View File

@ -448,7 +448,7 @@ void DIALOG_LIB_SYMBOL_PROPERTIES::OnGridCellChanging( wxGridEvent& event )
void DIALOG_LIB_SYMBOL_PROPERTIES::OnSymbolNameText( wxCommandEvent& event ) void DIALOG_LIB_SYMBOL_PROPERTIES::OnSymbolNameText( wxCommandEvent& event )
{ {
if( !m_Parent->IsSymbolFromSchematic() ) if( !m_Parent->IsSymbolFromSchematic() || m_OptionPower->IsChecked() )
m_grid->SetCellValue( VALUE_FIELD, FDC_VALUE, m_SymbolNameCtrl->GetValue() ); m_grid->SetCellValue( VALUE_FIELD, FDC_VALUE, m_SymbolNameCtrl->GetValue() );
} }

View File

@ -502,7 +502,7 @@ void FIELDS_GRID_TABLE<T>::SetValue( int aRow, int aCol, const wxString &aValue
value = fn.GetFullPath(); value = fn.GetFullPath();
} }
} }
else if( m_frame->IsType( FRAME_SCH_SYMBOL_EDITOR ) && aRow == VALUE_FIELD ) else if( m_parentType == SCH_SYMBOL_T && aRow == VALUE_FIELD )
{ {
value = EscapeString( value, CTX_LIBID ); value = EscapeString( value, CTX_LIBID );
} }