-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Illegal value for line
#6
Comments
found the same problem. cmd+enter works well for the last line. anyway, please fix this, this extension is awesome. |
Hey, I'm also a fan of Atom Hydrogen. Yesterday I found this extension and found the same problem. I've fixed it by editting the run-code.js. function runInferredCodeBlockAndMoveDown() {
const textEditor = vscode.window.activeTextEditor;
if (!textEditor) {
return;
}
const expandedCodeRange = inferCodeBlock(textEditor);
const inferredBlockText = textEditor.document.getText(expandedCodeRange);
console.log("inferredBlockText", inferredBlockText);
var empty_line_count = 0;
for(var i = expandedCodeRange.end.line; i >= expandedCodeRange.start.line; i--){
if(textEditor.document.lineAt(i).text.match(/^\s*$/)){
empty_line_count += 1;
}
else{
break;
}
}
console.log("empty_line_count", empty_line_count);
executeText(inferredBlockText);
//add a new line to the end of the code block
var endPosition;
var newSelection;
if(textEditor.document.lineCount <= expandedCodeRange.end.line + 1){
console.log("the last block")
if(expandedCodeRange.start.line == expandedCodeRange.end.line-empty_line_count){
console.log("the last block is a single line")
if(empty_line_count == 0){
console.log("need to add a new line")
vscode.commands.executeCommand("editor.action.insertLineAfter");
}
endPosition = new vscode_1.Position(expandedCodeRange.end.line + 1 - empty_line_count, 0);
newSelection = new vscode_1.Selection(endPosition, endPosition);
setSelectionAndMoveDown(textEditor, newSelection);
}
else{
console.log("the last block is a multi-line block")
endPosition = new vscode_1.Position(expandedCodeRange.end.line + 1 - empty_line_count, 0);
newSelection = new vscode_1.Selection(endPosition, endPosition);
setSelectionAndMoveDown(textEditor, newSelection);
if(empty_line_count == 0){
console.log("need to add a new line")
endPosition = new vscode_1.Position(expandedCodeRange.end.line + 1, 0);
newSelection = new vscode_1.Selection(endPosition, endPosition);
vscode.commands.executeCommand("editor.action.insertLineAfter");
setSelectionAndMoveDown(textEditor, newSelection);
}
}
}
else {
endPosition = new vscode_1.Position(expandedCodeRange.end.line + 1, 0);
newSelection = new vscode_1.Selection(endPosition, endPosition);
setSelectionAndMoveDown(textEditor, newSelection);
}
} |
@kylebarron Hi, is there any chance that this solution from @xclrr could be integrated in? I love this extension and I run into this issue multiple times a day. If there's anything I could do to help, please let me know. |
A PR is welcome. Some sort of test for this would be ideal, though I never figured out the initial setup for how to do tests on vscode |
@xclrr Would you like to do a PR? If so, great! If not, would you mind if I did a PR based on your code? @kylebarron I think a test for this would be trickier than ones I've done in the past but I'll have a look into it. |
@kylebarron I'm afraid I still don't have a solution for testing but would it be possible to merge @xclrr's PR in the meantime? |
this warning happens when running shift+enter on the last line of a text editor. Presumably I'm trying to set a line one after what exists in the editor
The text was updated successfully, but these errors were encountered: