MCPcopy
hub / github.com/jisaacks/GitGutter / is_enabled

Method is_enabled

modules/commands.py:70–129  ·  view source on GitHub ↗

Determine if `git_gutter` command is _enabled to execute.

(self, **kwargs)

Source from the content-addressed store, hash-verified

68 self._state = -1
69
70 def is_enabled(self, **kwargs):
71 """Determine if `git_gutter` command is _enabled to execute."""
72 view = self.view
73 state = 0
74
75 # Keep idle, if disabled by user setting
76 if not view.settings().get('git_gutter_enable', True):
77 state = 1
78 # Don't handle unattached views
79 elif not view.window():
80 state = 2
81 # Don't handle scratch views
82 elif view.is_scratch():
83 state = 3
84 # Don't handle readonly views
85 elif view.is_read_only():
86 state = 4
87 # Don't handle widgets
88 elif view.settings().get('is_widget'):
89 state = 5
90 # Don't handle SublimeREPL views
91 elif view.settings().get("repl"):
92 state = 6
93 # Don't handle binary files
94 elif view.encoding() == 'Hexadecimal':
95 state = 7
96 else:
97 queued_events = kwargs.get('events')
98 # Validate work tree on certain events only
99 validate = queued_events is None or queued_events & (
100 events.LOAD | events.ACTIVATED | events.POST_SAVE)
101 # Don't handle files outside a repository
102 if not self.git_handler.work_tree(validate):
103 state = 8
104 # Keep quite if git is not working properly
105 elif not self.git_handler.version(validate):
106 state = 9
107 # In WSL mode the repo must be located on a drive like (C:\path)
108 elif not self.git_handler.work_tree_supported():
109 state = 10
110 # Keep quite if a rebase operation is on the fly
111 elif self.git_handler.is_rebase_active():
112 state = 11
113
114 # Handle changed state
115 valid = state == 0
116 if self._state != state:
117 # File moved out of work-tree or repository gone
118 if not valid:
119 self.show_diff_handler.clear()
120 self.git_handler.view_cache.invalidate()
121 if settings.get('debug'):
122 utils.log_message('disabled for "%s" because %s' % (
123 os.path.basename(self.view.file_name() or 'untitled'),
124 DISABLED_REASON[state]))
125 # Save state for use in other modules
126 view.settings().set('git_gutter_is_enabled', valid)
127 # Save state for internal use

Callers 4

update_git_statusMethod · 0.45
is_enabledMethod · 0.45
_update_statusMethod · 0.45
run_blameFunction · 0.45

Calls 7

getMethod · 0.80
work_treeMethod · 0.80
versionMethod · 0.80
work_tree_supportedMethod · 0.80
is_rebase_activeMethod · 0.80
clearMethod · 0.80
invalidateMethod · 0.80

Tested by

no test coverage detected