I noticed that in the last build (3111) that functions called by another function are not higlighted correctly, unless I use the Monokai theme.
Surprisingly, I noticed this is true only for some C code of mine, where this is “broken”; tested on a “simple” C example file, it works fine.
[Solved] [Bug - 3111] - C called functions not highlighted correctly
Here it is: this is with the Monokai color scheme (working):
…and this is with the Monokai bright color scheme (broken):
P.S. By the way, there are some (minor) differences as well, for instance the pointers (&, *) are highlighted, and the equal symbol is highlighted, as well…
It looks like both Monokai
and Monokai bright
miss some scopes.
Unfortunately, to fix it, you have to make that theme “customized,” i.e., add missing scopes.
- To customize/modify your own theme, you may use PackageResourceViewer to find your
.tmTheme
file. It’s inColor Scheme - Default
package. - To find scope at cursor position, press ctrl+alt+shift+P.
Or, maybe, just use a good theme which already exists.
It’s just that these ship with ST by default and thus should be fixed upstream, making this still a valid report.
@Nova, for easier reproduction, please include the sample code as text too. You can wrap it in triple-fenced blocks or indent it by four spaces.
We likely need to pull Monokai Bright in sync with Monokai. I haven’t looked at what is supposed to be different, but I imagine we’ve just implemented some of the recent tweaks just to the main variant.
I lost the original source code file I used for the test. Anyhow, here is part of it:
#include <stdio.h>
#include <stdlib.h>
char *decimal_to_binary(int);
void TestMe( Uint8 *u8Test )
{
if( CallThisFunction( u8Test ))
{
CallAnotherFunction( u8Test );
}
}
void main( void )
{
int n, c, k;
char *pointer;
printf("Enter an integer in decimal number system\n");
scanf("%d", &n);
pointer = decimal_to_binary(n);
printf("Binary string of %d is: %s\n", n, t );
free( pointer );
return 0;
}
Seems that “library functions” (printf, scanf, …) are correctly highlighted, while custom functions are not.
Thank you all, for the quick reply.
I found another problem, with the same “scope”.
Some #ifdef is breaking the parsing of function - function calls in C syntax; here is (part of) my code for example:
static void MCU_SetSysClock()
{
/* PLL prescalers configuration settings */
#if( EXTAL == 40000 ) /* 40 MHz */
#if( PLL_0_CLOCK == 200000 )
#define PLL_MFD 40
#define PLL_PREDIV 4
#define PLL_RFD_PHI 2
#define PLL_RFD_PHI1 10 // PLL0_PH1 = 40MHz
#else
#error "Unsupported PLL0 clock frequency (PLL_0_CLOCK)"
#endif
/* Note: configuration below assumes use of PLL0_PH1 @40MHz as reference */
#if( PLL_1_CLOCK == 260000 )
#define PLL_1_MFD 26
#define PLL_1_RFD_PHI 2
/* Progressive clock switching values (ref. MPC5777M_PCS.xlsx) */
#define PCS_SDUR_VAL 0x10
#define PCS_PLL1_RATE 0x30
#define PCS_PLL1_INIT 0x4DF
#define PCS_PLL1_DIVE 0x3F79
#define PCS_PLL1_DIVS 0x45B7
#else
#error "Unsupported PLL1 clock frequency (PLL_1_CLOCK)"
#endif
#else
#error "Unsupported oscillator frequency (EXTAL)"
#endif
/* Other code here */
return;
} /* MCU_SetSysClock */
/**
********************************************************************************
*
* Function: MCU_initCache
* Description: Cache initialization (execute once at startup)
*
********************************************************************************
*/
static void MCU_InitCache(void)
{
}
Now, the first function is correctly highlighted:
While the second function is not:
Interestingly, removing the first #if (#if( PLL_0_CLOCK == 200000 )
) fixes the problem; removing (only) the second one does not.
There have been some improvements to the C family of syntaxes since build 3111. You can follow the instructions at https://github.com/sublimehq/Packages to try them. If you still see problems, please can you log an issue with the test case at https://github.com/sublimehq/Packages/issues - it is much easier to manage that way. Thanks!