Skip to content

Commit

Permalink
Merge pull request #15 from davidvarga/purematlab
Browse files Browse the repository at this point in the history
Purematlab
  • Loading branch information
davidvarga committed Jan 12, 2016
2 parents a95826e + dce779b commit 6eb0ed2
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
2 changes: 1 addition & 1 deletion @MBeautify/MBeautify.m
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@

[result, nCurrentNewlines] = handleMaximalNewLines(line, nCurrentNewlines, maximalNewLines);

[codeBefore, codeToFormat, codeAfter, selectedPosition, additionalInfo] = handleSource(source);
[isSourceAvailable, codeBefore, codeToFormat, codeAfter, selectedPosition, additionalInfo] = handleSource(source);
formattedSource = performFormatting(source, settingConf)
writeConfigurationFile(resStruct, fullRulesConfMFileName);

Expand Down
5 changes: 4 additions & 1 deletion @MBeautify/beautify.m
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@ function beautify(source)


% Handle the source
[codeBefore, codeToFormat, codeAfter, selectedPosition, additionalInfo] = MBeautify.handleSource(source);
[isSourceAvailable, codeBefore, codeToFormat, codeAfter, selectedPosition, additionalInfo] = MBeautify.handleSource(source);
if ~isSourceAvailable
return;
end
currentSelection = selectedPosition;

% Get the current configuration
Expand Down
12 changes: 8 additions & 4 deletions @MBeautify/handleSource.m
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
function [codeBefore, codeToFormat, codeAfter, selectedPosition, additionalInfo] = handleSource(source)
function [isSourceAvailable, codeBefore, codeToFormat, codeAfter, selectedPosition, additionalInfo] = handleSource(source)

codeToFormat = '';
additionalInfo = [];

isSourceAvailable = true;
selectedPosition = '';
sourceType = '';

if nargin < 1
Expand Down Expand Up @@ -31,11 +32,13 @@


currentEditorPage = matlab.desktop.editor.getActive();
selectedPosition = currentEditorPage.Selection;

if isempty(currentEditorPage)
isSourceAvailable = false;
return;
end
selectedPosition = currentEditorPage.Selection;


additionalInfo = currentEditorPage;
codeToFormat = currentEditorPage.Text;

Expand All @@ -46,6 +49,7 @@
if isempty(currentEditorPage)
codeToFormat = '';
additionalInfo = [];
isSourceAvailable = false;
return;
end

Expand Down

0 comments on commit 6eb0ed2

Please sign in to comment.