I would like to be able to capture keystrokes in a visual studio code extension. I need to know the new text that was either added or removed and the position of the change in the file.
I have registered a listener:
vscode.window.onDidChangeTextEditorSelection(handleChange)
and am getting updates on every single caret move but I am having a hard time getting added/removed text and positions from the event that is passed in. Currently, I am doing this in the handler:
function handleChange(event) {
console.log("Change in the text editor");
for(var i = 0;i < event.selections.length;i++)
{
var selection = event.selections[i];
console.log("Start- Line: (" + selection.start.line + ") Col: (" + selection.start.character + ") End- Line: (" + selection.end.line + ") Col: (" + selection.end.character + ")");
}
console.log(event);
}
The documentation mentions something called a TextDocumentContentChangeEvent which seems like exactly what I need but I don't know how to register a handler to receive these.