Skip to content

Commit

Permalink
Adding the value to __VERSION__ and __LINE__ macros in code completion
Browse files Browse the repository at this point in the history
  • Loading branch information
racz16 committed Mar 12, 2024
1 parent e628a10 commit 0f2fc7d
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/providers/glsl-completion-provider.ts
Expand Up @@ -146,11 +146,24 @@ export class GlslCompletionProvider implements CompletionItemProvider {

private addMacros(): void {
for (const macro of this.di.builtin.macros) {
const ci = new CompletionItem(macro, CompletionItemKind.Value);
const label = this.createMacroLabel(macro);
const ci = new CompletionItem(label, CompletionItemKind.Value);
this.items.push(ci);
}
}

private createMacroLabel(macro: string): CompletionItemLabel {
const label: CompletionItemLabel = {
label: macro,
};
if (macro === '__VERSION__') {
label.description = this.di.getVersion().toString();
} else if (macro == '__LINE__') {
label.description = `${this.position.line + this.di.getInjectionLineCount() + 1}`;
}
return label;
}

private getPreprocessorCompletionContext(mr: PreprocessorRegion): PreprocessorCompletionContext {
const text = mr.text.substring(0, this.position.character);
const words = new Array<string>();
Expand Down

0 comments on commit 0f2fc7d

Please sign in to comment.