Capturing keystrokes in visual studio code extension -
i able capture keystrokes in visual studio code extension. need know new text either added or removed , position of change in file.
i have registered listener:
vscode.window.ondidchangetexteditorselection(handlechange)
and getting updates on every single caret move having hard time getting added/removed text , positions event passed in. currently, doing in handler:
function handlechange(event) { console.log("change in text editor"); for(var = 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 called textdocumentcontentchangeevent seems need don't know how register handler receive these.
i discovered problem in original question. listening wrong event. textdocumentchangeevents have property called contentchanges returns textdocumentcontentchangeevents, use code:
vscode.workspace.ondidchangetextdocument(handlechange)
and pass in function called textdocumentchangeevent on every change file.
Comments
Post a Comment