Skip to content

Commit

Permalink
Settings cleanup
Browse files Browse the repository at this point in the history
Cleaned up custom delimiter code; invalid delimiters are reported and ignored.
Added settings to the preferences menu.
Renamed the settings file so it's easier to identify.
  • Loading branch information
wadetb committed Nov 19, 2014
1 parent c7ccb61 commit 6eb2714
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 1 deletion.
File renamed without changes.
35 changes: 35 additions & 0 deletions Main.sublime-menu
Original file line number Diff line number Diff line change
Expand Up @@ -59,5 +59,40 @@
]
}
]
},
{
"id": "preferences",
"children":
[
{
"caption": "Package Settings",
"id": "package-settings",
"children":
[
{
"caption": "Advanced CSV",
"children":
[
{
"caption": "Settings – Default",
"command": "open_file",
"args":
{
"file": "${packages}/Sublime-Text-Advanced-CSV/AdvancedCSV.sublime-settings"
}
},
{
"caption": "Settings – User",
"command": "open_file",
"args":
{
"file": "${packages}/User/AdvancedCSV.sublime-settings"
}
}
]
}
]
}
]
}
]
6 changes: 5 additions & 1 deletion csvplugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,16 @@ def __eq__(self, other): return self.Compare(other) == 0

class CSVMatrix:
def __init__(self):
self.settings = sublime.load_settings('Preferences.sublime-settings')
self.settings = sublime.load_settings('AdvancedCSV.sublime-settings')

self.rows = []
self.num_columns = 0
self.valid = False

self.delimiter = self.settings.get('delimiter')
if not isinstance(self.delimiter, str) or len(self.delimiter) != 1:
print("'{0}' is not a valid delimiter, reverting to ','.".format(self.delimiter))
self.delimiter = ','

def AddRow(self, row):
self.rows.append(row)
Expand Down

0 comments on commit 6eb2714

Please sign in to comment.