Quick Edit #13036

Closed
flapjack17 opened this Issue Jan 11, 2017 · 6 comments

Projects

None yet

4 participants

@flapjack17

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
@redmunds
Contributor

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

@flapjack17

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?

@redmunds
Contributor

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).

@petetnt
Member
petetnt commented Jan 12, 2017 edited

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

@redmunds
Contributor

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

@RaymondLim
Contributor
RaymondLim commented Jan 12, 2017 edited

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.

@RaymondLim RaymondLim self-assigned this Jan 12, 2017
@petetnt petetnt closed this in #13038 Jan 13, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment