(text: string, editLocation: any,
operation: string, targetDocument: TextDocument)
| 416 | } |
| 417 | |
| 418 | function 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 |
| 435 | export function trackLastActiveTextEditor(editor?: TextEditor): void { |
no outgoing calls
no test coverage detected