Open DBenS opened 1 year ago
I've put all my globals in an globals.mqh
file. Would be nice if we could include that in the settings.json and add it to intellisense
@L-I-V I am not proficient in VSC-Extensiondevelopment so I asked AI. Could this be a solution for adding some path/files to intellisense?
function ItemProvider() {
return {
provideCompletionItems(document, position) {
const loclang = language === 'zh-tw' ? 'zh-cn' : language,
path = vscode.Uri.file(pathModule.join(__dirname, '../', 'images', 'mql_icon_mini.png')),
range = document.getWordRangeAtPosition(position),
prefix = document.getText(range),
regEx = new RegExp(prefix, 'i');
// Add suggestions for a specific file
const filesIntellisense = getFilesIntellisense(prefix);
// Combine file items with existing items
const allItems = [...filesIntellisense, ...Object.values(obj_items).filter(name => name.label.substring(0, prefix.length).match(regEx))];
return allItems.map(match => {
const item = new vscode.CompletionItem(match.label, match.group);
item.insertText = new vscode.SnippetString(match.body);
item.detail = match.description[loclang] ? match.description[loclang] : match.description.en;
const contents = new vscode.MarkdownString();
contents.appendCodeblock(match.code.map(match => match.label)[0]);
if (match.group === 15) {
if (match.label in colorW) {
let clrRGB = colorW[match.label].split(',');
contents.appendMarkdown(
`<span style="background-color:#${rgbaToHex(+clrRGB[0], +clrRGB[1], +clrRGB[2])};">${Array.from({length: 55}, () => ' ').join('')}</span><br>\n`);
contents.supportHtml = true;
}
}
contents.appendMarkdown(`![](${path})`);
item.documentation = contents;
return item;
});
}
}
}
function getFilesIntellisense(prefix) {
const config = vscode.workspace.getConfiguration();
const fileItems = config.get('mql_tools.filesIntellisense', []);
const regEx = new RegExp(prefix, 'i');
return fileItems.filter(item => item.label.substring(0, prefix.length).match(regEx));
}
Just a suggestion: Intellisense doesn't reference global/local variables from the code and I think it's very useful when our code has a lot of them.
Would it be possible to have the same behavior as the MT5 editor, with these variables appearing after the second or third letter typed? I mean, the same feature shown with MQL5 functions, but with our own variables.
And congratulations to all of you for this excellent work!