Skip to content

Commit

Permalink
Merge pull request #24 from justinfx/23_comment_stripping
Browse files Browse the repository at this point in the history
Setting to disable single line comment stripping
  • Loading branch information
justinfx committed Mar 6, 2016
2 parents 97639b9 + 2cbd4cf commit 8fb5ac4
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 8 deletions.
17 changes: 11 additions & 6 deletions MayaSublime.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@
_settings = {
'host' : '127.0.0.1',
'mel_port' : 7001,
'py_port' : 7002
'py_port' : 7002,
'strip_sending_comments': True
}


Expand Down Expand Up @@ -126,11 +127,15 @@ def run(self, edit):

substr = self.view.substr
match = self.RX_COMMENT.match
stripComments = _settings['strip_comments']

# Build up all of the selected lines, while removing single-line comments
# to simplify the amount of data being sent.
for sel in selections:
snips.extend(line for line in substr(sel).splitlines() if not match(line))
if stripComments:
snips.extend(line for line in substr(sel).splitlines() if not match(line))
else:
snips.extend(substr(sel).splitlines())

mCmd = str(sep.join(snips))
if not mCmd:
Expand Down Expand Up @@ -172,11 +177,11 @@ def settings_obj():
return sublime.load_settings("MayaSublime.sublime-settings")

def sync_settings():
global _settings
so = settings_obj()
_settings['host'] = so.get('maya_hostname')
_settings['py_port'] = so.get('python_command_port')
_settings['mel_port'] = so.get('mel_command_port')
_settings['host'] = so.get('maya_hostname')
_settings['py_port'] = so.get('python_command_port')
_settings['mel_port'] = so.get('mel_command_port')
_settings['strip_comments'] = so.get('strip_sending_comments')



Expand Down
14 changes: 13 additions & 1 deletion MayaSublime.sublime-settings
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,18 @@
"python_command_port" : 7002,

// Maya commandPort to communicate via MEL
"mel_command_port" : 7001
"mel_command_port" : 7001,

// When sending selected code to Maya, strip
// out single-line comments in order to reduce
// the amount of data sent, and leave more room
// for more code to be sent
//
// A reason for disabling this feature is if you
// rely on accurate line numbers from errors in
// your code, reported by the Script Editor
//
// When sending whole files (nothing selected),
// comments are never stripped.
"strip_sending_comments": true
}
3 changes: 2 additions & 1 deletion messages.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"2.0.0": "messages/2.0.0.txt",
"2.1.0": "messages/2.1.0.txt",
"2.2.0": "messages/2.2.0.md"
"2.2.0": "messages/2.2.0.md",
"2.2.1": "messages/2.2.1.md"
}
3 changes: 3 additions & 0 deletions messages/2.2.1.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
MayaSublime 2.2.1 change log:

- Add option "strip_sending_comments" with a default value of true, controlling whether single-line comments from selected source code is stripped before sending code selections to Maya. Sending whole files (nothing selected) always sends executed all content. This was existing behavior to reduce the amount of data being sent to the commandPort, but can lead to incorrect line numbers when errors are reported in Maya. So you can disable it if you are having trouble debugging with what Maya reports.

0 comments on commit 8fb5ac4

Please sign in to comment.