mirror of
https://github.com/RustyRaptor/brackets.git
synced 2026-12-04 00:15:22 -07:00
Stop appending parentheses when inserting a function. Instead, show param hints only after the open parenthesis is entered.
This commit is contained in:
1 parent
3ce6ae29fc
commit
fbf246a6a1
2 files changed
+26
-29
No files matched your search
@@ -296,6 +296,29 @@ define(function (require, exports, module) {
|
||||
return $deferredPopUp;
|
||||
}
|
||||
|
||||
/**
|
||||
* Pop up a function hint on the line above the caret position if the character before
|
||||
* the current cursor is an open parenthesis
|
||||
*
|
||||
* @return {jQuery.Promise} - The promise will not complete until the
|
||||
* hint has completed. Returns null, if the function hint is already
|
||||
* displayed or there is no function hint at the cursor.
|
||||
*/
|
||||
function popUpHintAtOpenParen() {
|
||||
var functionInfo = session.getFunctionInfo();
|
||||
if (functionInfo.inFunctionCall) {
|
||||
var token = session.getToken();
|
||||
|
||||
if (token && token.string === "(") {
|
||||
return popUpHint();
|
||||
}
|
||||
} else {
|
||||
dismissHint();
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the parameter the cursor is on in bold when the cursor moves.
|
||||
* Dismiss the pop up when the cursor moves off the function.
|
||||
@@ -411,6 +434,7 @@ define(function (require, exports, module) {
|
||||
exports.installListeners = installListeners;
|
||||
exports.isHintDisplayed = isHintDisplayed;
|
||||
exports.popUpHint = popUpHint;
|
||||
exports.popUpHintAtOpenParen = popUpHintAtOpenParen;
|
||||
exports.setSession = setSession;
|
||||
exports.startCursorTracking = startCursorTracking;
|
||||
exports.stopCursorTracking = stopCursorTracking;
|
||||
|
||||
@@ -467,8 +467,7 @@ define(function (require, exports, module) {
|
||||
query = session.getQuery(),
|
||||
start = {line: cursor.line, ch: cursor.ch - query.length},
|
||||
end = {line: cursor.line, ch: cursor.ch},
|
||||
invalidPropertyName = false,
|
||||
displayFunctionHint = false;
|
||||
invalidPropertyName = false;
|
||||
|
||||
if (session.getType().property) {
|
||||
// if we're inserting a property name, we need to make sure the
|
||||
@@ -503,13 +502,6 @@ define(function (require, exports, module) {
|
||||
}
|
||||
}
|
||||
|
||||
// If the completion is for a valid function, then append
|
||||
// "()" to the function name.
|
||||
if (!invalidPropertyName && /^fn\(/.test(hint.type)) {
|
||||
completion = completion.concat("()");
|
||||
displayFunctionHint = true;
|
||||
}
|
||||
|
||||
// Replace the current token with the completion
|
||||
// HACK (tracking adobe/brackets#1688): We talk to the private CodeMirror instance
|
||||
// directly to replace the range instead of using the Document, as we should. The
|
||||
@@ -517,26 +509,6 @@ define(function (require, exports, module) {
|
||||
// inline editors are open.
|
||||
session.editor._codeMirror.replaceRange(completion, start, end);
|
||||
|
||||
// If displaying a function hint, move the cursor inside the "()".
|
||||
// Then pop-up a function hint.
|
||||
if (displayFunctionHint) {
|
||||
var pos = {line: start.line, ch: start.ch + completion.length - 1};
|
||||
|
||||
// stop cursor tracking before setting the cursor to avoid bringing
|
||||
// down the current hint.
|
||||
if (ParameterHintManager.isHintDisplayed()) {
|
||||
ParameterHintManager.stopCursorTracking(session);
|
||||
}
|
||||
|
||||
session.editor._codeMirror.setCursor(pos);
|
||||
|
||||
if (ParameterHintManager.isHintDisplayed()) {
|
||||
ParameterHintManager.startCursorTracking(session);
|
||||
}
|
||||
|
||||
ParameterHintManager.popUpHint(ParameterHintManager.PUSH_EXISTING_HINT);
|
||||
}
|
||||
|
||||
// Return false to indicate that another hinting session is not needed
|
||||
return false;
|
||||
};
|
||||
@@ -576,6 +548,7 @@ define(function (require, exports, module) {
|
||||
.on(HintUtils.eventName("change"), function (event, editor, changeList) {
|
||||
if (!ignoreChange) {
|
||||
ScopeManager.handleFileChange(changeList);
|
||||
ParameterHintManager.popUpHintAtOpenParen();
|
||||
}
|
||||
ignoreChange = false;
|
||||
});
|
||||
|
||||
Reference in new issue
Block a user