Skip to content

Commit 0c28417

Browse files
committed
Merge branch 'main' into rmohamme.fix-lint-for-ipynb
2 parents ad42b99 + d3444b1 commit 0c28417

File tree

13 files changed

+823
-397
lines changed

13 files changed

+823
-397
lines changed

README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,13 @@ MATLAB language server supports these editors by installing the corresponding ex
2828

2929
### Unreleased
3030

31+
### 1.2.6
32+
Release date: 2024-09-20
33+
34+
Fixed:
35+
* Patches CVE-2024-43788
36+
* Resolves issue preventing code navigation and variable renaming for variables followed by a matrix operation (e.g. `x.^2`)
37+
3138
### 1.2.5
3239
Release date: 2024-08-16
3340

package-lock.json

Lines changed: 582 additions & 385 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "matlab-language-server",
3-
"version": "1.2.5",
3+
"version": "1.2.6",
44
"description": "Language Server for MATLAB code",
55
"main": "./src/index.ts",
66
"bin": "./out/index.js",
@@ -23,6 +23,7 @@
2323
"devDependencies": {
2424
"@types/mocha": "^10.0.6",
2525
"@types/node": "^18.7.18",
26+
"@types/sinon": "^17.0.3",
2627
"@types/which": "^2.0.1",
2728
"@types/yargs": "^17.0.12",
2829
"@typescript-eslint/eslint-plugin": "^5.36.1",
@@ -34,6 +35,7 @@
3435
"eslint-plugin-promise": "^6.0.1",
3536
"mocha": "^10.4.0",
3637
"node-loader": "^2.0.0",
38+
"sinon": "^18.0.0",
3739
"ts-loader": "^9.4.1",
3840
"ts-node": "^10.9.2",
3941
"typescript": "^4.8.3",

src/ClientConnection.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { _Connection, createConnection, ProposedFeatures } from "vscode-language
44
export type Connection = _Connection
55

66
export default class ClientConnection {
7-
private static connection: Connection
7+
private static connection: Connection | undefined
88

99
/**
1010
* Retrieves the connection to the client. If no connection currently exists,
@@ -26,7 +26,15 @@ export default class ClientConnection {
2626
*
2727
* @param connection The connection object to set
2828
*/
29-
public static setConnection (connection: Connection): void {
29+
public static _setConnection (connection: Connection): void {
3030
ClientConnection.connection = connection
3131
}
32+
33+
/**
34+
* Clears the current connection.
35+
* This API is primarily meant for testing purposes.
36+
*/
37+
public static _clearConnection (): void {
38+
ClientConnection.connection = undefined
39+
}
3240
}

src/lifecycle/MatlabCommunicationManager.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
/// <reference types="node" />
2+
/// <reference types="node" />
23
import { ChildProcess } from 'child_process';
34
declare const Faye: any;
45
declare type Client = typeof Faye.Client;

src/lifecycle/MatlabCommunicationManager.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/logging/Logger.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class Logger {
1616
private readonly languageServerLogFile: string
1717
private readonly matlabLogFile: string
1818

19-
private readonly console: RemoteConsole
19+
private console?: RemoteConsole
2020

2121
constructor () {
2222
// Create Log Directory
@@ -32,9 +32,10 @@ class Logger {
3232
// Get name of log file
3333
this.languageServerLogFile = path.join(this.logDir, SERVER_LOG)
3434
this.matlabLogFile = path.join(this.logDir, MATLAB_LOG)
35+
}
3536

36-
// Get log console
37-
this.console = ClientConnection.getConnection().console
37+
public initialize (console: RemoteConsole): void {
38+
this.console = console
3839

3940
this.log(`Log Directory: ${this.logDir}`)
4041
}

src/providers/formatting/FormatSupportProvider.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ interface FormatDocumentResponse {
1717
* include formatting a range witin the documemt.
1818
*/
1919
class FormatSupportProvider {
20-
private readonly REQUEST_CHANNEL = '/matlabls/formatDocument/request'
21-
private readonly RESPONSE_CHANNEL = '/matlabls/formatDocument/response'
20+
readonly REQUEST_CHANNEL = '/matlabls/formatDocument/request'
21+
readonly RESPONSE_CHANNEL = '/matlabls/formatDocument/response'
2222

2323
constructor (private matlabLifecycleManager: MatlabLifecycleManager) {}
2424

src/server.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@ export async function startServer () {
3030
// Create a connection for the server
3131
const connection = ClientConnection.getConnection()
3232

33+
// Initialize Logger
34+
Logger.initialize(connection.console)
35+
3336
// Instantiate services
3437
const pathResolver = new PathResolver()
3538
const matlabLifecycleManager = new MatlabLifecycleManager()

src/utils/ExpressionUtils.ts

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ import { TextDocument } from 'vscode-languageserver-textdocument'
44
import { Position } from 'vscode-languageserver'
55
import { getTextOnLine } from './TextDocumentUtils'
66

7+
const DOTTED_IDENTIFIER_REGEX = /\b(?:[a-zA-Z][\w]*)(?:\.[a-zA-Z][\w]*)*\b/ // Matches a word followed by optional dotted words
8+
79
/**
810
* Represents a code expression, either a single identifier or a dotted expression.
911
* For example, "plot" or "pkg.Class.func".
@@ -82,7 +84,6 @@ export function getExpressionAtPosition (textDocument: TextDocument, position: P
8284
* @returns An object containing the string identifier at the position, as well as the column number at which the identifier starts.
8385
*/
8486
function getIdentifierAtPosition (textDocument: TextDocument, position: Position): { identifier: string, start: number } {
85-
const DOTTED_IDENTIFIER_REGEX = /[\w.]+/
8687
let lineText = getTextOnLine(textDocument, position.line)
8788

8889
const result = {
@@ -94,12 +95,19 @@ function getIdentifierAtPosition (textDocument: TextDocument, position: Position
9495
let offset = 0
9596

9697
while (matchResults != null) {
97-
if (matchResults.index == null || matchResults.index > position.character) {
98-
// Already passed the cursor - no match found
98+
if (matchResults.index == null) {
99+
// No result found
99100
break
100101
}
101102

102103
const startChar = offset + matchResults.index
104+
105+
if (startChar > position.character) {
106+
// Passed the cursor - no match found
107+
break
108+
}
109+
110+
103111
if (startChar + matchResults[0].length >= position.character) {
104112
// Found overlapping identifier
105113
result.identifier = matchResults[0]

0 commit comments

Comments
 (0)