Skip to content

Commit 02ff685

Browse files
authored
Merge pull request #56 from mathworks/dklilley/release/1.3.1
MATLAB language server - v1.3.1
2 parents c7ac9f9 + 6dfe929 commit 02ff685

31 files changed

+512
-133
lines changed

README.md

+10
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,16 @@ MATLAB language server supports these editors by installing the corresponding ex
2626

2727
### Unreleased
2828

29+
### 1.3.1
30+
Release date: 2025-01-23
31+
32+
Added:
33+
* The language server keeps the MATLAB path in sync with the client workspace, improving code navigation, completions, and execution
34+
35+
Fixed:
36+
* Resolves errors with document formatting when using with MATLAB R2025a
37+
* Resolves errors with execution and debugging when using with MATLAB R2022a
38+
2939
### 1.3.0
3040
Release date: 2024-12-18
3141

matlab/+matlabls/+handlers/FormatSupportHandler.m

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ function handleFormatRequest (this, msg)
2828
cleanupObj3 = setTemporaryValue(s.matlab.editor.tab.IndentSize, msg.tabSize); %#ok<NASGU>
2929

3030
% Format code
31-
response.data = indentcode(codeToFormat, 'matlab'); % This will pull from the user's MATLAB® settings.
31+
response.data = indentcode(codeToFormat); % This will pull from the user's MATLAB® settings.
3232

3333
% Send formatted code
3434
responseChannel = strcat(this.ResponseChannel, '/', msg.channelId);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
classdef (Hidden) PathSynchronizerHandler < matlabls.handlers.FeatureHandler
2+
% PATHSYNCHRONIZERHANDLER The feature handler to support synchronizing the MATLAB path
3+
% with the client's workspace. This provides access points to add and remove from the path,
4+
% as well as get/set MATLAB's current working directory.
5+
6+
% Copyright 2024 The MathWorks, Inc.
7+
8+
properties (Access = private)
9+
CdRequestChannel = "/matlabls/pathSynchronizer/cd/request"
10+
11+
PwdRequestChannel = "/matlabls/pathSynchronizer/pwd/request"
12+
PwdResponseChannel = "/matlabls/pathSynchronizer/pwd/response"
13+
14+
AddPathRequestChannel = "/matlabls/pathSynchronizer/addpath/request"
15+
RmPathRequestChannel = "/matlabls/pathSynchronizer/rmpath/request"
16+
end
17+
18+
methods
19+
function this = PathSynchronizerHandler ()
20+
this.RequestSubscriptions(1) = matlabls.internal.CommunicationManager.subscribe(this.CdRequestChannel, @this.handleCdRequest);
21+
this.RequestSubscriptions(2) = matlabls.internal.CommunicationManager.subscribe(this.PwdRequestChannel, @this.handlePwdRequest);
22+
this.RequestSubscriptions(3) = matlabls.internal.CommunicationManager.subscribe(this.AddPathRequestChannel, @this.handleAddPathRequest);
23+
this.RequestSubscriptions(4) = matlabls.internal.CommunicationManager.subscribe(this.RmPathRequestChannel, @this.handleRmPathRequest);
24+
end
25+
end
26+
27+
methods (Access = private)
28+
function handleCdRequest (~, msg)
29+
path = msg.path;
30+
31+
try
32+
cd(path)
33+
catch e
34+
disp('Error during `cd` operation:')
35+
disp(e.message)
36+
end
37+
end
38+
39+
function handlePwdRequest (this, msg)
40+
try
41+
currentPath = pwd();
42+
43+
responseChannel = strcat(this.PwdResponseChannel, '/', msg.channelId);
44+
matlabls.internal.CommunicationManager.publish(responseChannel, currentPath);
45+
catch e
46+
disp('Error during `pwd` operation:')
47+
disp(e.message)
48+
end
49+
end
50+
51+
function handleAddPathRequest (~, msg)
52+
paths = msg.paths;
53+
paths = strjoin(paths, pathsep);
54+
55+
try
56+
addpath(paths)
57+
catch e
58+
disp('Error during `addpath` operation:')
59+
disp(e.message)
60+
end
61+
end
62+
63+
function handleRmPathRequest (~, msg)
64+
paths = msg.paths;
65+
paths = strjoin(paths, pathsep);
66+
67+
try
68+
rmpath(paths)
69+
catch e
70+
disp('Error during `rmpath` operation:')
71+
disp(e.message)
72+
end
73+
end
74+
end
75+
end

matlab/+matlabls/MatlabLanguageServerHelper.m

+1
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ function initializeFeatureHandlers (this)
3232
this.FeatureHandlers(end + 1) = matlabls.handlers.LintingSupportHandler();
3333
this.FeatureHandlers(end + 1) = matlabls.handlers.NavigationSupportHandler();
3434
this.FeatureHandlers(end + 1) = matlabls.handlers.FoldingSupportHandler();
35+
this.FeatureHandlers(end + 1) = matlabls.handlers.PathSynchronizerHandler();
3536
end
3637
end
3738
end

package-lock.json

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "matlab-language-server",
3-
"version": "1.3.0",
3+
"version": "1.3.1",
44
"description": "Language Server for MATLAB code",
55
"main": "./src/index.ts",
66
"bin": "./out/index.js",

src/debug/DebugServices.ts

+3-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2024 The MathWorks, Inc.
1+
// Copyright 2024-2025 The MathWorks, Inc.
22

33
import { IMVM } from '../mvm/impl/MVM'
44
import EventEmitter from 'events';
@@ -78,7 +78,7 @@ enum Events {
7878

7979
export class DebugServices extends EventEmitter {
8080
static Events = Events;
81-
private _mvm: IMVM;
81+
private readonly _mvm: IMVM;
8282

8383
constructor (mvm: IMVM) {
8484
super();
@@ -93,10 +93,9 @@ export class DebugServices extends EventEmitter {
9393
this._mvm.on('ContinueExecutionEvent', (data: MatlabData) => {
9494
this.emit(DebugServices.Events.DBCont);
9595
});
96-
this._mvm.on('ChangeCurrentWorkspace', (data: MatlabData) => {
96+
this._mvm.on('ChangeCurrentWorkspaceEvent', (data: MatlabData) => {
9797
this.emit(DebugServices.Events.DBWorkspaceChanged);
9898
});
99-
10099
this._mvm.on('AddLineNumberBreakpointEvent', (data: MatlabData) => {
101100
this.emit(DebugServices.Events.BreakpointAdded, new BreakpointInfo(data.Filespec, data.LineNumber, data.Condition, data.whichAnonymousFunctionOnCurrentLine));
102101
});

0 commit comments

Comments
 (0)