Skip to content

Commit c2f55c2

Browse files
committed
Current view only saves if there are modifications closes adampresley#32
1 parent 4157883 commit c2f55c2

File tree

2 files changed

+13
-6
lines changed

2 files changed

+13
-6
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,8 @@ of the FILE protocol.
112112

113113
## Change History
114114

115+
* 05/15/2014:
116+
* Current view only saves if there are modifications
115117
* 07/03/2013:
116118
* Changes to support Sublime Text 3 and Python 3
117119
* 06/15/2013:

ViewInBrowserCommand.py

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
#
22
# History:
33
#
4+
# 05/15/2014:
5+
# - Current view only saves if there are modifications
6+
#
47
# 07/03/2013:
58
# - Changes to support Sublime Text 3 and Python 3
69
#
@@ -67,7 +70,7 @@ def run(self, edit, browser=None):
6770
fileToOpen = self.view.file_name()
6871

6972
#
70-
# If we've specified settings for a local server environment
73+
# If we've specified settings for a local server environment
7174
# use them
7275
#
7376
if projectSettings:
@@ -93,10 +96,12 @@ def run(self, edit, browser=None):
9396
#
9497
# Ensure the current view is saved
9598
#
96-
self.view.window().run_command("save")
99+
if self.view.is_dirty():
100+
print("File %s is dirty. Saving..." % (fileToOpen,))
101+
self.view.window().run_command("save")
102+
97103

98-
99-
#
104+
#
100105
# And open. If the settings file contains a valid selected browser use that
101106
# command to open this file. Otherwise use the system default.
102107
#
@@ -178,7 +183,7 @@ def getUserShellFolders(self):
178183
import _winreg
179184
else:
180185
import winreg as _winreg
181-
186+
182187
return_dict = {}
183188

184189
# First open the registry hive
@@ -197,7 +202,7 @@ def getUserShellFolders(self):
197202
return return_dict
198203

199204
# Nothing failed above, so enumerate through all the Shell Folder values and return in a dictionary
200-
# This relies on error at end of
205+
# This relies on error at end of
201206
try:
202207
for i in range(0, _winreg.QueryInfoKey(Key)[1]):
203208
name, value, val_type = _winreg.EnumValue(Key, i)

0 commit comments

Comments
 (0)