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
This commit is contained in:
Jeff Young 2022-03-10 13:45:03 +00:00
parent eb9ccea559
commit a9eb7a0e28
3 changed files with 14 additions and 4 deletions

View File

@ -143,6 +143,14 @@ 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 += "{brace}"; converted += "{brace}";
else if( c == '/' ) else if( c == '/' )
converted += "{slash}"; converted += "{slash}";
@ -238,8 +246,10 @@ wxString EscapeString( const wxString& aSource, ESCAPE_CONTEXT aContext )
converted += c; converted += c;
} }
else else
{
converted += c; converted += c;
} }
}
return converted; return converted;
} }

View File

@ -446,7 +446,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

@ -561,7 +561,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 );
} }