MCPcopy Index your code
hub / github.com/REditorSupport/vscode-R / runTextInTerm

Function runTextInTerm

src/rTerminal.ts:265–298  ·  view source on GitHub ↗
(text: string, execute: boolean = true)

Source from the content-addressed store, hash-verified

263}
264
265export async function runTextInTerm(text: string, execute: boolean = true): Promise<void> {
266 if (isGuestSession) {
267 rGuestService?.requestRunTextInTerm(text);
268 } else {
269 const term = await chooseTerminal();
270 if (term === undefined) {
271 return;
272 }
273 if (config().get<boolean>('bracketedPaste')) {
274 // Surround with ANSI control characters for bracketed paste mode
275 text = `\x1b[200~${text}\x1b[201~`;
276 term.sendText(text, execute);
277 } else {
278 const rtermSendDelay: number = config().get('rtermSendDelay') || 8;
279 const split = text.split('\n');
280 const last_split = split.length - 1;
281 for (const [count, line] of split.entries()) {
282 if (count > 0) {
283 await delay(rtermSendDelay); // Increase delay if RTerm can't handle speed.
284 }
285
286 // Avoid sending newline on last line
287 if (count === last_split && !execute) {
288 term.sendText(line, false);
289 } else {
290 term.sendText(line);
291 }
292 }
293 }
294 setFocus(term);
295 // Scroll console to see latest output
296 await vscode.commands.executeCommand('workbench.action.terminal.scrollToBottom');
297 }
298}
299
300function setFocus(term: vscode.Terminal) {
301 const focus: string = config().get('source.focus') || 'editor';

Callers 15

clearFunction · 0.90
saveWorkspaceFunction · 0.90
loadWorkspaceFunction · 0.90
viewItemFunction · 0.90
removeItemFunction · 0.90
attachActiveFunction · 0.90
launchAddinPickerFunction · 0.90
sendCodeToRTerminalFunction · 0.90
previewEnvironmentFunction · 0.90
previewDataframeFunction · 0.90
knitRmdMethod · 0.90
handleMessageMethod · 0.90

Calls 6

configFunction · 0.90
delayFunction · 0.90
chooseTerminalFunction · 0.85
setFocusFunction · 0.85
requestRunTextInTermMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected