Don't un-comment code with alt+. in the query tool. It's only supposed to respond to ctrl/cmd+. Fixes #2769

This commit is contained in:
Murtuza Zabuawala
2017-12-13 15:58:00 +00:00
committed by Dave Page
parent d02a0de8c9
commit 937984f2dc

View File

@@ -23,16 +23,22 @@ function keyboardShortcuts(sqlEditorController, queryToolActions, event) {
} else if (keyCode === F8_KEY) { } else if (keyCode === F8_KEY) {
event.preventDefault(); event.preventDefault();
queryToolActions.download(sqlEditorController); queryToolActions.download(sqlEditorController);
} else if (((this.isMac() && event.metaKey) || (!this.isMac() && event.ctrlKey)) && } else if ((
event.shiftKey && keyCode === FWD_SLASH_KEY) { (this.isMac() && event.metaKey) ||
(!this.isMac() && event.ctrlKey)
) && !event.altKey && event.shiftKey && keyCode === FWD_SLASH_KEY) {
_stopEventPropagation(); _stopEventPropagation();
queryToolActions.commentBlockCode(sqlEditorController); queryToolActions.commentBlockCode(sqlEditorController);
} else if (((this.isMac() && event.metaKey) || (!this.isMac() && event.ctrlKey)) && } else if ((
keyCode === FWD_SLASH_KEY) { (this.isMac() && !this.isKeyCtrlAltShift(event) && event.metaKey) ||
(!this.isMac() && !this.isKeyAltShift(event) && event.ctrlKey)
) && keyCode === FWD_SLASH_KEY) {
_stopEventPropagation(); _stopEventPropagation();
queryToolActions.commentLineCode(sqlEditorController); queryToolActions.commentLineCode(sqlEditorController);
} else if (((this.isMac() && event.metaKey) || (!this.isMac() && event.ctrlKey)) && } else if ((
keyCode === PERIOD_KEY) { (this.isMac() && !this.isKeyCtrlAltShift(event) && event.metaKey) ||
(!this.isMac() && !this.isKeyAltShift(event) && event.ctrlKey)
) && keyCode === PERIOD_KEY) {
_stopEventPropagation(); _stopEventPropagation();
queryToolActions.uncommentLineCode(sqlEditorController); queryToolActions.uncommentLineCode(sqlEditorController);
} }
@@ -49,7 +55,27 @@ function isMac() {
return window.navigator.platform.search('Mac') != -1; return window.navigator.platform.search('Mac') != -1;
} }
function isKeyCtrlAlt(event) {
return event.ctrlKey || event.altKey;
}
function isKeyAltShift(event) {
return event.altKey || event.shiftKey;
}
function isKeyCtrlShift(event) {
return event.ctrlKey || event.shiftKey;
}
function isKeyCtrlAltShift(event) {
return event.ctrlKey || event.altKey || event.shiftKey;
}
module.exports = { module.exports = {
processEvent: keyboardShortcuts, processEvent: keyboardShortcuts,
isMac: isMac, isMac: isMac,
isKeyCtrlAlt: isKeyCtrlAlt,
isKeyAltShift: isKeyAltShift,
isKeyCtrlShift: isKeyCtrlShift,
isKeyCtrlAltShift: isKeyCtrlAltShift
}; };