Skip to content

Commit 53cbc83

Browse files
author
Tal Hadad
committed
Merge branch 'master' into custom-lsp-command
2 parents 4317609 + c513feb commit 53cbc83

8 files changed

Lines changed: 73 additions & 53 deletions

File tree

CHANGELOG.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,21 @@
44

55
You can check all of our changes from [Release Page](https://github.com/REditorSupport/vscode-R/releases)
66

7+
## [2.8.3](https://github.com/REditorSupport/vscode-R/releases/tag/v2.8.3)
8+
9+
Enhancements:
10+
11+
* Substitute variables in `r.rpath` and `r.rterm` settings. (#1444)
12+
* Improve code chunk handling in base .R files. (#1454, thanks @kylebutts)
13+
14+
Fixes:
15+
16+
* Fix multiline smart-knit (#1493)
17+
* Fix RMD Progress Bar (#1491)
18+
* Remove `.` as an R language `editor.wordSeparators` (#1503, thanks @opasche)
19+
* `numeric_version()` wants character as of R 4.4 (#1520, #1523, thanks @jennybc and @pawelru)
20+
* Handle terminals created by vscode-Python (#1511, thanks @tomasnobrega)
21+
722
## [2.8.2](https://github.com/REditorSupport/vscode-R/releases/tag/v2.8.2)
823

924
Enhancements:

R/session/init.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ init_first <- function() {
1616
return()
1717
}
1818

19-
# check requried packages
19+
# check required packages
2020
required_packages <- c("jsonlite", "rlang")
2121
missing_packages <- required_packages[
2222
!vapply(required_packages, requireNamespace,

R/session/rstudioapi.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -230,14 +230,14 @@ viewer <- function(url, height = NULL) {
230230
}
231231

232232
getVersion <- function() {
233-
numeric_version(0)
233+
numeric_version("0")
234234
}
235235

236236
versionInfo <- function() {
237237
list(
238238
citation = "",
239239
mode = "vscode",
240-
version = numeric_version(0),
240+
version = numeric_version("0"),
241241
release_name = "vscode"
242242
)
243243
}

package.json

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "r",
33
"displayName": "R",
44
"description": "R Extension for Visual Studio Code",
5-
"version": "2.8.2",
5+
"version": "2.8.3",
66
"author": "REditorSupport",
77
"license": "SEE LICENSE IN LICENSE",
88
"publisher": "REditorSupport",
@@ -2057,6 +2057,11 @@
20572057
}
20582058
}
20592059
},
2060+
"configurationDefaults": {
2061+
"[r]": {
2062+
"editor.wordSeparators": "`~!@#$%^&*()-=+[{]}\\|;:'\",<>/"
2063+
}
2064+
},
20602065
"taskDefinitions": [
20612066
{
20622067
"type": "R",
@@ -2181,7 +2186,7 @@
21812186
"ag-grid-community": "^30.2.0",
21822187
"cheerio": "1.0.0-rc.10",
21832188
"crypto": "^1.0.1",
2184-
"ejs": "^3.1.7",
2189+
"ejs": "^3.1.10",
21852190
"fs-extra": "^10.0.0",
21862191
"highlight.js": "^10.7.3",
21872192
"httpgd": "^0.1.6",

src/rTerminal.ts

Lines changed: 29 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -174,10 +174,18 @@ export function deleteTerminal(term: vscode.Terminal): void {
174174
}
175175

176176
export async function chooseTerminal(): Promise<vscode.Terminal | undefined> {
177+
// VSCode Python's extension creates hidden terminal with string 'Deactivate'
178+
// For now ignore terminals with this string
179+
const ignoreTermIdentifier = 'Deactivate';
180+
181+
// Filter out terminals to be ignored
182+
const visibleTerminals = vscode.window.terminals.filter(terminal => {
183+
return !terminal.name.toLowerCase().includes(ignoreTermIdentifier);
184+
});
185+
177186
if (config().get('alwaysUseActiveTerminal')) {
178-
if (vscode.window.terminals.length < 1) {
187+
if (visibleTerminals.length < 1) {
179188
void vscode.window.showInformationMessage('There are no open terminals.');
180-
181189
return undefined;
182190
}
183191

@@ -189,53 +197,32 @@ export async function chooseTerminal(): Promise<vscode.Terminal | undefined> {
189197
for (let i = 0; i < vscode.window.terminals.length; i++){
190198
msg += `Terminal ${i}: ${vscode.window.terminals[i].name} `;
191199
}
192-
if (vscode.window.terminals.length > 0) {
193-
const rTermNameOptions = ['R', 'R Interactive'];
194-
if (vscode.window.activeTerminal !== undefined) {
195-
const activeTerminalName = vscode.window.activeTerminal.name;
196-
if (rTermNameOptions.includes(activeTerminalName)) {
197-
return vscode.window.activeTerminal;
198-
}
199-
for (let i = vscode.window.terminals.length - 1; i >= 0; i--){
200-
const terminal = vscode.window.terminals[i];
201-
const terminalName = terminal.name;
202-
if (rTermNameOptions.includes(terminalName)) {
203-
terminal.show(true);
204-
return terminal;
205-
}
206-
}
207-
} else {
208-
msg += `B. There are ${vscode.window.terminals.length} terminals: `;
209-
for (let i = 0; i < vscode.window.terminals.length; i++){
210-
msg += `Terminal ${i}: ${vscode.window.terminals[i].name} `;
211-
}
212-
// Creating a terminal when there aren't any already does not seem to set activeTerminal
213-
if (vscode.window.terminals.length === 1) {
214-
const activeTerminalName = vscode.window.terminals[0].name;
215-
if (rTermNameOptions.includes(activeTerminalName)) {
216-
return vscode.window.terminals[0];
217-
}
218-
} else {
219-
msg += `C. There are ${vscode.window.terminals.length} terminals: `;
220-
for (let i = 0; i < vscode.window.terminals.length; i++){
221-
msg += `Terminal ${i}: ${vscode.window.terminals[i].name} `;
222-
}
223-
console.info(msg);
224-
void vscode.window.showErrorMessage('Error identifying terminal! Please run command "Developer: Toggle Developer Tools", find the message starting with "[chooseTerminal]", and copy the message to https://github.com/REditorSupport/vscode-R/issues');
225200

226-
return undefined;
227-
}
228-
}
229-
}
201+
const rTermNameOptions = ['R', 'R Interactive'];
202+
203+
const validRTerminals = visibleTerminals.filter(terminal => {
204+
return rTermNameOptions.includes(terminal.name);
205+
});
230206

231-
if (rTerm === undefined) {
207+
if (validRTerminals.length > 0) {
208+
// If there is an active terminal that is an R terminal, use it
209+
if (vscode.window.activeTerminal && rTermNameOptions.includes(vscode.window.activeTerminal.name)) {
210+
return vscode.window.activeTerminal;
211+
}
212+
// Otherwise, use last valid R terminal
213+
const rTerminal = validRTerminals[validRTerminals.length - 1];
214+
rTerminal.show(true);
215+
return rTerminal;
216+
} else {
217+
// If no valid R terminals are found, create a new one
218+
console.info(msg);
232219
await createRTerm(true);
233220
await delay(200); // Let RTerm warm up
221+
return rTerm;
234222
}
235-
236-
return rTerm;
237223
}
238224

225+
239226
export async function runSelectionInTerm(moveCursor: boolean, useRepl = true): Promise<void> {
240227
const selection = getSelection();
241228
if (!selection) {

src/rmarkdown/knit.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ export class RMarkdownKnitManager extends RMarkdownManager {
137137
// precedence:
138138
// knit > site > configuration
139139
if (yamlParams?.['knit']) {
140-
const knitParam = yamlParams['knit'];
140+
const knitParam = yamlParams['knit'].trim();
141141
knitCommand = outputFormat ?
142142
`${knitParam}(${docPath}, output_format = '${outputFormat}')` :
143143
`${knitParam}(${docPath})`;

src/rmarkdown/manager.ts

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,8 +123,8 @@ export abstract class RMarkdownManager {
123123

124124
}
125125
const percentRegex = /[0-9]+(?=%)/g;
126+
const divisionRegex = /([0-9]+)\/([0-9]+)/g;
126127
const percentRegOutput = dat.match(percentRegex);
127-
128128
if (percentRegOutput) {
129129
for (const item of percentRegOutput) {
130130
const perc = Number(item);
@@ -136,7 +136,20 @@ export abstract class RMarkdownManager {
136136
);
137137
currentProgress = perc;
138138
}
139+
} else {
140+
const divisionRegOutput = divisionRegex.exec(dat);
141+
if (divisionRegOutput) {
142+
const perc = Math.ceil(parseInt(divisionRegOutput[1]) / parseInt(divisionRegOutput[2]) * 100);
143+
progress?.report(
144+
{
145+
increment: perc - currentProgress,
146+
message: `${perc}%`
147+
}
148+
);
149+
currentProgress = perc;
150+
}
139151
}
152+
140153
if (token?.isCancellationRequested) {
141154
if (childProcess) {
142155
resolve(childProcess);

yarn.lock

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1136,10 +1136,10 @@ duplexer2@~0.1.4:
11361136
dependencies:
11371137
readable-stream "^2.0.2"
11381138

1139-
ejs@^3.1.7:
1140-
version "3.1.7"
1141-
resolved "https://registry.npmjs.org/ejs/-/ejs-3.1.7.tgz"
1142-
integrity sha512-BIar7R6abbUxDA3bfXrO4DSgwo8I+fB5/1zgujl3HLLjwd6+9iOnrT+t3grn2qbk9vOgBubXOFwX2m9axoFaGw==
1139+
ejs@^3.1.10:
1140+
version "3.1.10"
1141+
resolved "https://registry.yarnpkg.com/ejs/-/ejs-3.1.10.tgz#69ab8358b14e896f80cc39e62087b88500c3ac3b"
1142+
integrity sha512-UeJmFfOrAQS8OJWPZ4qtgHyWExa088/MtK5UEyoJGFH67cDEXkZSviOiKRCZ4Xij0zxI3JECgYs3oKx+AizQBA==
11431143
dependencies:
11441144
jake "^10.8.5"
11451145

0 commit comments

Comments
 (0)