Closed brukted closed 4 years ago
I would add that it worked for me a few times and then stopped. I cloned the tree and debugged the extension and I think I see a problem. But this is my first time looking at VSCode extension stuff, so I can't be sure. But I made the change below which worked. I'll test with my change further, but it seems you defined selections and then didn't use it when you called create. So my thought is that maybe openSourceFile reset the active doc and selection pointer so now it doesn't point to something valid.
export default function () {
if (vscode.window.activeTextEditor && vscode.window.activeTextEditor.selection) {
if (vscode.window.activeTextEditor) {
var activeEditor = vscode.window.activeTextEditor;
var selections = activeEditor.selections;
selections = selections.sort((a:vscode.Selection, b: vscode.Selection) => a.start.isAfter(b.start) ? 1 : -1);
Helpers.openSourceFile().then(function (doc : vscode.TextEditor) {
//create(activeEditor, activeEditor.selections, doc);
create(activeEditor, selections, doc);
});
}
}
}
Hello.
I need more information to find out why this happening. Did you move the cursor on declaration before use command? It would be awesome if you s send gif screencast. Also extension working with regexes and maybe your function is not detectable by regex so please send a code sample and tell where you right-clicked.
For my case I had the cursor set to the middle of a function declaration in a namespace header. I right click select "Create Implementation". When I debugged the extension, a breakpoint on create in the function above showed that activeEditor.Selections was pointing to a different file and file offset 0,0. I thought your intent above was to sort selections and send it to create. Otherwise it seems you define selections and never use it.
Anyways, I could get a video if you really need it, but I would have to revert my private build of your extension which is working for me now. Just let me know.
@paulelong Hello
I appreciate contributing.
create calling itself for all selections. It removes a selection and calls itself again and again until all selections have implementations.
https://github.com/amir9480/vscode-cpp-helper/blob/master/src/commands/CreateImplementation.ts#L96
If this fixed the problem and didn't change the behavior of extension please make a pull request.
Thanks! This extension looks very helpful to me so I appreciate the work. I think I'm in sync with your master as I just cloned it today, Git pull is also saying I'm up to date. Originally I reproduced with the version in the Extensions UI. Did you just make this fix?
@paulelong No my last change was for last week.
The problem exists in the released version 0.1.0. I just dl'd it today and that's when I experienced the problem. It also exists with the latest revision of your github repro which I cloned today. Then there is still an issue?
@paulelong I didn't experience this issue and don't have a clue why this happening. If issue exists and your solution solved it make a pull request.
Please update to v0.1.1 and if this issue still exists let me know.
Clicking on function name and creating implementation doesn't work and says "Function not dectected" but create implementation here works.