MCPcopy Create free account
hub / github.com/REditorSupport/vscode-R / normaliseEditText

Function normaliseEditText

src/rstudioapi.ts:418–432  ·  view source on GitHub ↗
(text: string, editLocation: any,
    operation: string, targetDocument: TextDocument)

Source from the content-addressed store, hash-verified

416}
417
418function normaliseEditText(text: string, editLocation: any,
419 operation: string, targetDocument: TextDocument) {
420 // in a document with lines, does the line position extend past the existing
421 // lines in the document? rstudioapi adds a newline in this case, so must we.
422 // n_lines is a count, line is 0 indexed position hence + 1
423 const editStartLine = operation === 'insertText' ?
424 editLocation[0] :
425 editLocation.start[0];
426 if (editStartLine === 'Inf' ||
427 (editStartLine + 1 > targetDocument.lineCount && targetDocument.lineCount > 0)) {
428 return (text + '\n');
429 } else {
430 return text;
431 }
432}
433
434// window.onActiveTextEditorDidChange handler
435export function trackLastActiveTextEditor(editor?: TextEditor): void {

Callers 1

insertOrModifyTextFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected