brackets-archive / bracketsIssues

Archive of issues in brackets.
0 stars 0 forks source link

[CLOSED] Quick Edit #11079

Open core-ai-bot opened 3 years ago

core-ai-bot commented 3 years ago

Issue by sean0x72 Wednesday Jan 11, 2017 at 20:10 GMT Originally opened as https://github.com/adobe/brackets/issues/13036


Qiuck edit does not display the entire funciton when using template literatles with embed expressions.

function hi(name){
    let works `hello ` + name;
    let breaks = `Hello ${name}`; // quick edit ends on this line
    console.log(works); //the rest of the function does not return
    console.log(breaks);
}

When using quick edit code is displayed like:

function hi(name){
    let works `hello ` + name; 
    let breaks = `Hello ${name}`; // quick edit ends on this line
core-ai-bot commented 3 years ago

Comment by redmunds Wednesday Jan 11, 2017 at 20:55 GMT


Backtick (`) is not a valid string delimiter is JS. It should work if you use either single (') or double (") quotes instead.

core-ai-bot commented 3 years ago

Comment by sean0x72 Wednesday Jan 11, 2017 at 21:29 GMT


The first line of the function is using backticks and returns the next line. the problem appears to arise when using a place holder ${}; How is the backtick not valid?

core-ai-bot commented 3 years ago

Comment by redmunds Wednesday Jan 11, 2017 at 23:08 GMT


QuickEdit is implemented for JS. Whatever language you are using that uses backtick for string delimiters is not supported.

But, it looks like the ${} placeholder you are using could also be used outside of a string, so my original suggestion doesn't fix all cases of the problem. That type of placeholder is also not supported (i.e. the closing brace is interpretted as the end of the function).

core-ai-bot commented 3 years ago

Comment by petetnt Thursday Jan 12, 2017 at 00:29 GMT


@redmunds backticks (and ${expressions} are used in templated literals and are valid string delimeters (in ES2015)

core-ai-bot commented 3 years ago

Comment by redmunds Thursday Jan 12, 2017 at 01:36 GMT


@petetnt Thanks for clarifying. Either CodeMirror does not yet support ES2015, or Brackets is not recognizing the new tokens.

core-ai-bot commented 3 years ago

Comment by RaymondLim Thursday Jan 12, 2017 at 02:50 GMT


It is a bug in the regular expression that is used to extract functions in https://github.com/adobe/brackets/blob/master/src/language/JSUtils.js. It is mistakenly taking the closing brace inside the template literal as the closing brace of the function definition.

update: Actually, it is not the regexp that I originally thought. It is in _getFunctionEndOffset where we're mistakenly identifying the } in a template literal as the function end.