diff --git a/for grouping b/for grouping new file mode 100644 index 0000000000..ddfd61639b --- /dev/null +++ b/for grouping @@ -0,0 +1,618 @@ +commit 6a767e86275bc52594e27104a9b8cbe687d3f992 +Author: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> +Date: Thu Jun 12 15:47:46 2025 +0000 + + Port TypeScript PR #60304: More rigorous ASI prevention when emitting return/yield + + Co-authored-by: andrewbranch <3277153+andrewbranch@users.noreply.github.com> + +diff --git a/internal/printer/printer.go b/internal/printer/printer.go +index 4f9c7197..a2cad69d 100644 +--- a/internal/printer/printer.go ++++ b/internal/printer/printer.go +@@ -2950,7 +2950,110 @@ func (p *Printer) emitPartiallyEmittedExpression(node *ast.PartiallyEmittedExpre + } +  + func (p *Printer) willEmitLeadingNewLine(node *ast.Expression) bool { +- return false // !!! check if node will emit a leading comment that contains a trailing newline ++ // !!! check if node will emit a leading comment that contains a trailing newline ++ // For now, assume that PartiallyEmittedExpression with comments may have leading newlines ++ if node.Kind == ast.KindPartiallyEmittedExpression { ++ // This is a simplification - in a real implementation we'd check the actual comments ++ // but for now, let's assume partially emitted expressions might have leading newlines ++ return true ++ } ++ return false ++} ++ ++// parenthesizeExpressionForNoAsi wraps an expression in parens if we would emit a leading comment that would introduce a line separator ++// between the node and its parent. ++func (p *Printer) parenthesizeExpressionForNoAsi(node *ast.Expression) *ast.Expression { ++ if !p.commentsDisabled { ++ switch node.Kind { ++ case ast.KindPartiallyEmittedExpression: ++ if p.willEmitLeadingNewLine(node) { ++ parseNode := p.emitContext.ParseNode(node.AsNode()) ++ if parseNode != nil && parseNode.Kind == ast.KindParenthesizedExpression { ++ // If the original node was a parenthesized expression, restore it to preserve comment and source map emit ++ parens := p.emitContext.Factory.NewParenthesizedExpression(node.AsPartiallyEmittedExpression().Expression) ++ p.emitContext.SetOriginal(parens, node.AsNode()) ++ parens.Loc = parseNode.Loc ++ return parens ++ } ++ return p.emitContext.Factory.NewParenthesizedExpression(node) ++ } ++ return p.emitContext.Factory.UpdatePartiallyEmittedExpression( ++ node.AsPartiallyEmittedExpression(), ++ p.parenthesizeExpressionForNoAsi(node.AsPartiallyEmittedExpression().Expression), ++ ) ++ case ast.KindPropertyAccessExpression: ++ return p.emitContext.Factory.UpdatePropertyAccessExpression( ++ node.AsPropertyAccessExpression(), ++ p.parenthesizeExpressionForNoAsi(node.AsPropertyAccessExpression().Expression), ++ node.AsPropertyAccessExpression().QuestionDotToken, ++ node.AsPropertyAccessExpression().Name(), ++ ) ++ case ast.KindElementAccessExpression: ++ return p.emitContext.Factory.UpdateElementAccessExpression( ++ node.AsElementAccessExpression(), ++ p.parenthesizeExpressionForNoAsi(node.AsElementAccessExpression().Expression), ++ node.AsElementAccessExpression().QuestionDotToken, ++ node.AsElementAccessExpression().ArgumentExpression, ++ ) ++ case ast.KindCallExpression: ++ return p.emitContext.Factory.UpdateCallExpression( ++ node.AsCallExpression(), ++ p.parenthesizeExpressionForNoAsi(node.AsCallExpression().Expression), ++ node.AsCallExpression().QuestionDotToken, ++ node.AsCallExpression().TypeArguments, ++ node.AsCallExpression().Arguments, ++ ) ++ case ast.KindTaggedTemplateExpression: ++ return p.emitContext.Factory.UpdateTaggedTemplateExpression( ++ node.AsTaggedTemplateExpression(), ++ p.parenthesizeExpressionForNoAsi(node.AsTaggedTemplateExpression().Tag), ++ node.AsTaggedTemplateExpression().QuestionDotToken, ++ node.AsTaggedTemplateExpression().TypeArguments, ++ node.AsTaggedTemplateExpression().Template, ++ ) ++ case ast.KindPostfixUnaryExpression: ++ return p.emitContext.Factory.UpdatePostfixUnaryExpression( ++ node.AsPostfixUnaryExpression(), ++ p.parenthesizeExpressionForNoAsi(node.AsPostfixUnaryExpression().Operand), ++ ) ++ case ast.KindBinaryExpression: ++ return p.emitContext.Factory.UpdateBinaryExpression( ++ node.AsBinaryExpression(), ++ node.AsBinaryExpression().Modifiers(), ++ p.parenthesizeExpressionForNoAsi(node.AsBinaryExpression().Left), ++ node.AsBinaryExpression().Type, ++ node.AsBinaryExpression().OperatorToken, ++ node.AsBinaryExpression().Right, ++ ) ++ case ast.KindConditionalExpression: ++ return p.emitContext.Factory.UpdateConditionalExpression( ++ node.AsConditionalExpression(), ++ p.parenthesizeExpressionForNoAsi(node.AsConditionalExpression().Condition), ++ node.AsConditionalExpression().QuestionToken, ++ node.AsConditionalExpression().WhenTrue, ++ node.AsConditionalExpression().ColonToken, ++ node.AsConditionalExpression().WhenFalse, ++ ) ++ case ast.KindAsExpression: ++ return p.emitContext.Factory.UpdateAsExpression( ++ node.AsAsExpression(), ++ p.parenthesizeExpressionForNoAsi(node.AsAsExpression().Expression), ++ node.AsAsExpression().Type, ++ ) ++ case ast.KindSatisfiesExpression: ++ return p.emitContext.Factory.UpdateSatisfiesExpression( ++ node.AsSatisfiesExpression(), ++ p.parenthesizeExpressionForNoAsi(node.AsSatisfiesExpression().Expression), ++ node.AsSatisfiesExpression().Type, ++ ) ++ case ast.KindNonNullExpression: ++ return p.emitContext.Factory.UpdateNonNullExpression( ++ node.AsNonNullExpression(), ++ p.parenthesizeExpressionForNoAsi(node.AsNonNullExpression().Expression), ++ ) ++ } ++ } ++ return node + } +  + func (p *Printer) emitExpressionNoASI(node *ast.Expression, precedence ast.OperatorPrecedence) { +@@ -2966,12 +3069,8 @@ func (p *Printer) emitExpressionNoASI(node *ast.Expression, precedence ast.Opera + // a; + // } + // Due to ASI, this would result in a `return` with no value followed by an unreachable expression statement. +- if !p.commentsDisabled && node.Kind == ast.KindPartiallyEmittedExpression && p.willEmitLeadingNewLine(node) { +- // !!! if there is an original parse tree node, restore it with location to preserve comments and source maps. +- p.emitExpression(node, ast.OperatorPrecedenceParentheses) +- } else { +- p.emitExpression(node, precedence) +- } ++ node = p.parenthesizeExpressionForNoAsi(node) ++ p.emitExpression(node, precedence) + } +  + func (p *Printer) emitExpression(node *ast.Expression, precedence ast.OperatorPrecedence) { +diff --git a/testdata/baselines/reference/submodule/conformance/returnStatementNoAsiAfterTransform(target=es5).js b/testdata/baselines/reference/submodule/conformance/returnStatementNoAsiAfterTransform(target=es5).js +index af3c2fde..65e3b705 100644 +--- a/testdata/baselines/reference/submodule/conformance/returnStatementNoAsiAfterTransform(target=es5).js ++++ b/testdata/baselines/reference/submodule/conformance/returnStatementNoAsiAfterTransform(target=es5).js +@@ -67,52 +67,52 @@ function t10() { +  + //// [returnStatementNoAsiAfterTransform.js] + function t1() { +- return  ++ return (  + // comment +- a; ++ a);  + } + function t2() { +- return  ++ return (  + // comment +- a + 1; ++ a) + 1;  + } + function t3() { +- return  ++ return (  + // comment +- a ? 0 : 1; ++ a) ? 0 : 1;  + } + function t4() { +- return  ++ return (  + // comment +- a.b; ++ a).b;  + } + function t5() { +- return  ++ return (  + // comment +- a[a]; ++ a)[a];  + } + function t6() { +- return  ++ return (  + // comment +- a(); ++ a)();  + } + function t7() { +- return  ++ return (  + // comment +- a ``; ++ a) ``;  + } + function t8() { +- return  ++ return (  + // comment +- a; ++ a);  + } + function t9() { +- return  ++ return (  + // comment +- a; ++ a);  + } + function t10() { +- return  ++ return (  + // comment +- a; ++ a);  + } +diff --git a/testdata/baselines/reference/submodule/conformance/returnStatementNoAsiAfterTransform(target=es5).js.diff b/testdata/baselines/reference/submodule/conformance/returnStatementNoAsiAfterTransform(target=es5).js.diff +index 531a57c9..245619e9 100644 +--- a/testdata/baselines/reference/submodule/conformance/returnStatementNoAsiAfterTransform(target=es5).js.diff ++++ b/testdata/baselines/reference/submodule/conformance/returnStatementNoAsiAfterTransform(target=es5).js.diff +@@ -9,72 +9,14 @@ + - return cooked; + -}; + function t1() { +-- return ( +-+ return  ++ return ( + // comment +-- a); +-+ a; +- } +- function t2() { +-- return ( +-+ return  +- // comment +-- a) + 1; +-+ a + 1; +- } +- function t3() { +-- return ( +-+ return  +- // comment +-- a) ? 0 : 1; +-+ a ? 0 : 1; +- } +- function t4() { +-- return ( +-+ return  +- // comment +-- a).b; +-+ a.b; +- } +- function t5() { +-- return ( +-+ return  +- // comment +-- a)[a]; +-+ a[a]; +- } +- function t6() { +-- return ( +-+ return  +- // comment +-- a)(); +-+ a(); +- } ++@@= skipped -37, +33 lines =@@ + function t7() { +-- return ( +-+ return  ++ return ( + // comment + - a)(__makeTemplateObject([""], [""])); +-+ a ``; +++ a) ``; + } + function t8() { +-- return ( +-+ return  +- // comment +-- a); +-+ a; +- } +- function t9() { +-- return ( +-+ return  +- // comment +-- a); +-+ a; +- } +- function t10() { +-- return ( +-+ return  +- // comment +-- a); +-+ a; +- } +\ No newline at end of file ++ return ( +\ No newline at end of file +diff --git a/testdata/baselines/reference/submodule/conformance/returnStatementNoAsiAfterTransform(target=esnext).js b/testdata/baselines/reference/submodule/conformance/returnStatementNoAsiAfterTransform(target=esnext).js +index af3c2fde..65e3b705 100644 +--- a/testdata/baselines/reference/submodule/conformance/returnStatementNoAsiAfterTransform(target=esnext).js ++++ b/testdata/baselines/reference/submodule/conformance/returnStatementNoAsiAfterTransform(target=esnext).js +@@ -67,52 +67,52 @@ function t10() { +  + //// [returnStatementNoAsiAfterTransform.js] + function t1() { +- return  ++ return (  + // comment +- a; ++ a);  + } + function t2() { +- return  ++ return (  + // comment +- a + 1; ++ a) + 1;  + } + function t3() { +- return  ++ return (  + // comment +- a ? 0 : 1; ++ a) ? 0 : 1;  + } + function t4() { +- return  ++ return (  + // comment +- a.b; ++ a).b;  + } + function t5() { +- return  ++ return (  + // comment +- a[a]; ++ a)[a];  + } + function t6() { +- return  ++ return (  + // comment +- a(); ++ a)();  + } + function t7() { +- return  ++ return (  + // comment +- a ``; ++ a) ``;  + } + function t8() { +- return  ++ return (  + // comment +- a; ++ a);  + } + function t9() { +- return  ++ return (  + // comment +- a; ++ a);  + } + function t10() { +- return  ++ return (  + // comment +- a; ++ a);  + } +diff --git a/testdata/baselines/reference/submodule/conformance/returnStatementNoAsiAfterTransform(target=esnext).js.diff b/testdata/baselines/reference/submodule/conformance/returnStatementNoAsiAfterTransform(target=esnext).js.diff +deleted file mode 100644 +index b5a0ca9f..00000000 +--- a/testdata/baselines/reference/submodule/conformance/returnStatementNoAsiAfterTransform(target=esnext).js.diff ++++ /dev/null +@@ -1,75 +0,0 @@ +---- old.returnStatementNoAsiAfterTransform(target=esnext).js +-+++ new.returnStatementNoAsiAfterTransform(target=esnext).js +-@@= skipped -66, +66 lines =@@ +- +- //// [returnStatementNoAsiAfterTransform.js] +- function t1() { +-- return ( +-+ return  +- // comment +-- a); +-+ a; +- } +- function t2() { +-- return ( +-+ return  +- // comment +-- a) + 1; +-+ a + 1; +- } +- function t3() { +-- return ( +-+ return  +- // comment +-- a) ? 0 : 1; +-+ a ? 0 : 1; +- } +- function t4() { +-- return ( +-+ return  +- // comment +-- a).b; +-+ a.b; +- } +- function t5() { +-- return ( +-+ return  +- // comment +-- a)[a]; +-+ a[a]; +- } +- function t6() { +-- return ( +-+ return  +- // comment +-- a)(); +-+ a(); +- } +- function t7() { +-- return ( +-+ return  +- // comment +-- a) ``; +-+ a ``; +- } +- function t8() { +-- return ( +-+ return  +- // comment +-- a); +-+ a; +- } +- function t9() { +-- return ( +-+ return  +- // comment +-- a); +-+ a; +- } +- function t10() { +-- return ( +-+ return  +- // comment +-- a); +-+ a; +- } +\ No newline at end of file +diff --git a/testdata/baselines/reference/submodule/conformance/yieldStatementNoAsiAfterTransform(target=esnext).js b/testdata/baselines/reference/submodule/conformance/yieldStatementNoAsiAfterTransform(target=esnext).js +index c0af9e05..71167e54 100644 +--- a/testdata/baselines/reference/submodule/conformance/yieldStatementNoAsiAfterTransform(target=esnext).js ++++ b/testdata/baselines/reference/submodule/conformance/yieldStatementNoAsiAfterTransform(target=esnext).js +@@ -67,52 +67,52 @@ function *t10() { +  + //// [yieldStatementNoAsiAfterTransform.js] + function* t1() { +- yield  ++ yield (  + // comment +- a; ++ a);  + } + function* t2() { +- yield  ++ yield (  + // comment +- a + 1; ++ a) + 1;  + } + function* t3() { +- yield  ++ yield (  + // comment +- a ? 0 : 1; ++ a) ? 0 : 1;  + } + function* t4() { +- yield  ++ yield (  + // comment +- a.b; ++ a).b;  + } + function* t5() { +- yield  ++ yield (  + // comment +- a[a]; ++ a)[a];  + } + function* t6() { +- yield  ++ yield (  + // comment +- a(); ++ a)();  + } + function* t7() { +- yield  ++ yield (  + // comment +- a ``; ++ a) ``;  + } + function* t8() { +- yield  ++ yield (  + // comment +- a; ++ a);  + } + function* t9() { +- yield  ++ yield (  + // comment +- a; ++ a);  + } + function* t10() { +- yield  ++ yield (  + // comment +- a; ++ a);  + } +diff --git a/testdata/baselines/reference/submodule/conformance/yieldStatementNoAsiAfterTransform(target=esnext).js.diff b/testdata/baselines/reference/submodule/conformance/yieldStatementNoAsiAfterTransform(target=esnext).js.diff +deleted file mode 100644 +index 1cd12174..00000000 +--- a/testdata/baselines/reference/submodule/conformance/yieldStatementNoAsiAfterTransform(target=esnext).js.diff ++++ /dev/null +@@ -1,75 +0,0 @@ +---- old.yieldStatementNoAsiAfterTransform(target=esnext).js +-+++ new.yieldStatementNoAsiAfterTransform(target=esnext).js +-@@= skipped -66, +66 lines =@@ +- +- //// [yieldStatementNoAsiAfterTransform.js] +- function* t1() { +-- yield ( +-+ yield  +- // comment +-- a); +-+ a; +- } +- function* t2() { +-- yield ( +-+ yield  +- // comment +-- a) + 1; +-+ a + 1; +- } +- function* t3() { +-- yield ( +-+ yield  +- // comment +-- a) ? 0 : 1; +-+ a ? 0 : 1; +- } +- function* t4() { +-- yield ( +-+ yield  +- // comment +-- a).b; +-+ a.b; +- } +- function* t5() { +-- yield ( +-+ yield  +- // comment +-- a)[a]; +-+ a[a]; +- } +- function* t6() { +-- yield ( +-+ yield  +- // comment +-- a)(); +-+ a(); +- } +- function* t7() { +-- yield ( +-+ yield  +- // comment +-- a) ``; +-+ a ``; +- } +- function* t8() { +-- yield ( +-+ yield  +- // comment +-- a); +-+ a; +- } +- function* t9() { +-- yield ( +-+ yield  +- // comment +-- a); +-+ a; +- } +- function* t10() { +-- yield ( +-+ yield  +- // comment +-- a); +-+ a; +- } +\ No newline at end of file diff --git a/internal/printer/printer.go b/internal/printer/printer.go index 4f9c719793..f97855d655 100644 --- a/internal/printer/printer.go +++ b/internal/printer/printer.go @@ -2950,7 +2950,76 @@ func (p *Printer) emitPartiallyEmittedExpression(node *ast.PartiallyEmittedExpre } func (p *Printer) willEmitLeadingNewLine(node *ast.Expression) bool { - return false // !!! check if node will emit a leading comment that contains a trailing newline + // Check if node will emit a leading comment that contains a trailing newline + if p.commentsDisabled || p.currentSourceFile == nil { + return false + } + + pos := node.Pos() + if ast.PositionIsSynthesized(pos) || pos == p.containerPos { + return false + } + + // Get leading comments for this node + text := p.currentSourceFile.Text() + hasLeadingNewLineComment := false + for comment := range scanner.GetLeadingCommentRanges(p.emitContext.Factory.AsNodeFactory(), text, pos) { + if p.shouldWriteComment(comment) { + // Check if this comment will cause a newline to be emitted + if comment.Kind == ast.KindSingleLineCommentTrivia { + // Single line comments always end with a newline + hasLeadingNewLineComment = true + break + } else if comment.Kind == ast.KindMultiLineCommentTrivia { + // Multi-line comments may contain newlines or cause newlines + commentText := text[comment.Pos():comment.End()] + // Check if the comment ends with a newline or contains newlines + if len(commentText) > 0 && (commentText[len(commentText)-1] == '\n' || commentText[len(commentText)-1] == '\r') { + hasLeadingNewLineComment = true + break + } + // Also check if the comment contains internal newlines + for i := 0; i < len(commentText); i++ { + if commentText[i] == '\n' || commentText[i] == '\r' { + hasLeadingNewLineComment = true + break + } + } + } + } + } + + // If this node doesn't have leading comments, check if any of its child expressions do + if !hasLeadingNewLineComment { + switch node.Kind { + case ast.KindAsExpression: + return p.willEmitLeadingNewLine(node.AsAsExpression().Expression) + case ast.KindSatisfiesExpression: + return p.willEmitLeadingNewLine(node.AsSatisfiesExpression().Expression) + case ast.KindNonNullExpression: + return p.willEmitLeadingNewLine(node.AsNonNullExpression().Expression) + case ast.KindParenthesizedExpression: + return p.willEmitLeadingNewLine(node.AsParenthesizedExpression().Expression) + case ast.KindPropertyAccessExpression: + return p.willEmitLeadingNewLine(node.AsPropertyAccessExpression().Expression) + case ast.KindElementAccessExpression: + return p.willEmitLeadingNewLine(node.AsElementAccessExpression().Expression) + case ast.KindCallExpression: + return p.willEmitLeadingNewLine(node.AsCallExpression().Expression) + case ast.KindTaggedTemplateExpression: + return p.willEmitLeadingNewLine(node.AsTaggedTemplateExpression().Tag) + case ast.KindPostfixUnaryExpression: + return p.willEmitLeadingNewLine(node.AsPostfixUnaryExpression().Operand) + case ast.KindBinaryExpression: + return p.willEmitLeadingNewLine(node.AsBinaryExpression().Left) + case ast.KindConditionalExpression: + return p.willEmitLeadingNewLine(node.AsConditionalExpression().Condition) + case ast.KindPartiallyEmittedExpression: + return p.willEmitLeadingNewLine(node.AsPartiallyEmittedExpression().Expression) + } + } + + return hasLeadingNewLineComment } func (p *Printer) emitExpressionNoASI(node *ast.Expression, precedence ast.OperatorPrecedence) { @@ -2966,7 +3035,7 @@ func (p *Printer) emitExpressionNoASI(node *ast.Expression, precedence ast.Opera // a; // } // Due to ASI, this would result in a `return` with no value followed by an unreachable expression statement. - if !p.commentsDisabled && node.Kind == ast.KindPartiallyEmittedExpression && p.willEmitLeadingNewLine(node) { + if !p.commentsDisabled && p.willEmitLeadingNewLine(node) { // !!! if there is an original parse tree node, restore it with location to preserve comments and source maps. p.emitExpression(node, ast.OperatorPrecedenceParentheses) } else { diff --git a/tdout on a dedicated line b/tdout on a dedicated line new file mode 100644 index 0000000000..333a0b576c --- /dev/null +++ b/tdout on a dedicated line @@ -0,0 +1,258 @@ + + SSUUMMMMAARRYY OOFF LLEESSSS CCOOMMMMAANNDDSS + + Commands marked with * may be preceded by a number, _N. + Notes in parentheses indicate the behavior if _N is given. + A key preceded by a caret indicates the Ctrl key; thus ^K is ctrl-K. + + h H Display this help. + q :q Q :Q ZZ Exit. + --------------------------------------------------------------------------- + + MMOOVVIINNGG + + e ^E j ^N CR * Forward one line (or _N lines). + y ^Y k ^K ^P * Backward one line (or _N lines). + f ^F ^V SPACE * Forward one window (or _N lines). + b ^B ESC-v * Backward one window (or _N lines). + z * Forward one window (and set window to _N). + w * Backward one window (and set window to _N). + ESC-SPACE * Forward one window, but don't stop at end-of-file. + d ^D * Forward one half-window (and set half-window to _N). + u ^U * Backward one half-window (and set half-window to _N). + ESC-) RightArrow * Right one half screen width (or _N positions). + ESC-( LeftArrow * Left one half screen width (or _N positions). + ESC-} ^RightArrow Right to last column displayed. + ESC-{ ^LeftArrow Left to first column. + F Forward forever; like "tail -f". + ESC-F Like F but stop when search pattern is found. + r ^R ^L Repaint screen. + R Repaint screen, discarding buffered input. + --------------------------------------------------- + Default "window" is the screen height. + Default "half-window" is half of the screen height. + --------------------------------------------------------------------------- + + SSEEAARRCCHHIINNGG + + /_p_a_t_t_e_r_n * Search forward for (_N-th) matching line. + ?_p_a_t_t_e_r_n * Search backward for (_N-th) matching line. + n * Repeat previous search (for _N-th occurrence). + N * Repeat previous search in reverse direction. + ESC-n * Repeat previous search, spanning files. + ESC-N * Repeat previous search, reverse dir. & spanning files. + ESC-u Undo (toggle) search highlighting. + ESC-U Clear search highlighting. + &_p_a_t_t_e_r_n * Display only matching lines. + --------------------------------------------------- + A search pattern may begin with one or more of: + ^N or ! Search for NON-matching lines. + ^E or * Search multiple files (pass thru END OF FILE). + ^F or @ Start search at FIRST file (for /) or last file (for ?). + ^K Highlight matches, but don't move (KEEP position). + ^R Don't use REGULAR EXPRESSIONS. + ^W WRAP search if no match found. + --------------------------------------------------------------------------- + + JJUUMMPPIINNGG + + g < ESC-< * Go to first line in file (or line _N). + G > ESC-> * Go to last line in file (or line _N). + p % * Go to beginning of file (or _N percent into file). + t * Go to the (_N-th) next tag. + T * Go to the (_N-th) previous tag. + { ( [ * Find close bracket } ) ]. + } ) ] * Find open bracket { ( [. + ESC-^F _<_c_1_> _<_c_2_> * Find close bracket _<_c_2_>. + ESC-^B _<_c_1_> _<_c_2_> * Find open bracket _<_c_1_>. + --------------------------------------------------- + Each "find close bracket" command goes forward to the close bracket + matching the (_N-th) open bracket in the top line. + Each "find open bracket" command goes backward to the open bracket + matching the (_N-th) close bracket in the bottom line. + + m_<_l_e_t_t_e_r_> Mark the current top line with . + M_<_l_e_t_t_e_r_> Mark the current bottom line with . + '_<_l_e_t_t_e_r_> Go to a previously marked position. + '' Go to the previous position. + ^X^X Same as '. + ESC-M_<_l_e_t_t_e_r_> Clear a mark. + --------------------------------------------------- + A mark is any upper-case or lower-case letter. + Certain marks are predefined: + ^ means beginning of the file + $ means end of the file + --------------------------------------------------------------------------- + + CCHHAANNGGIINNGG FFIILLEESS + + :e [_f_i_l_e] Examine a new file. + ^X^V Same as :e. + :n * Examine the (_N-th) next file from the command line. + :p * Examine the (_N-th) previous file from the command line. + :x * Examine the first (or _N-th) file from the command line. + :d Delete the current file from the command line list. + = ^G :f Print current file name. + --------------------------------------------------------------------------- + + MMIISSCCEELLLLAANNEEOOUUSS CCOOMMMMAANNDDSS + + -_<_f_l_a_g_> Toggle a command line option [see OPTIONS below]. + --_<_n_a_m_e_> Toggle a command line option, by name. + __<_f_l_a_g_> Display the setting of a command line option. + ___<_n_a_m_e_> Display the setting of an option, by name. + +_c_m_d Execute the less cmd each time a new file is examined. + + !_c_o_m_m_a_n_d Execute the shell command with $SHELL. + |XX_c_o_m_m_a_n_d Pipe file between current pos & mark XX to shell command. + s _f_i_l_e Save input to a file. + v Edit the current file with $VISUAL or $EDITOR. + V Print version number of "less". + --------------------------------------------------------------------------- + + OOPPTTIIOONNSS + + Most options may be changed either on the command line, + or from within less by using the - or -- command. + Options may be given in one of two forms: either a single + character preceded by a -, or a name preceded by --. + + -? ........ --help + Display help (from command line). + -a ........ --search-skip-screen + Search skips current screen. + -A ........ --SEARCH-SKIP-SCREEN + Search starts just after target line. + -b [_N] .... --buffers=[_N] + Number of buffers. + -B ........ --auto-buffers + Don't automatically allocate buffers for pipes. + -c ........ --clear-screen + Repaint by clearing rather than scrolling. + -d ........ --dumb + Dumb terminal. + -D xx_c_o_l_o_r . --color=xx_c_o_l_o_r + Set screen colors. + -e -E .... --quit-at-eof --QUIT-AT-EOF + Quit at end of file. + -f ........ --force + Force open non-regular files. + -F ........ --quit-if-one-screen + Quit if entire file fits on first screen. + -g ........ --hilite-search + Highlight only last match for searches. + -G ........ --HILITE-SEARCH + Don't highlight any matches for searches. + -h [_N] .... --max-back-scroll=[_N] + Backward scroll limit. + -i ........ --ignore-case + Ignore case in searches that do not contain uppercase. + -I ........ --IGNORE-CASE + Ignore case in all searches. + -j [_N] .... --jump-target=[_N] + Screen position of target lines. + -J ........ --status-column + Display a status column at left edge of screen. + -k [_f_i_l_e] . --lesskey-file=[_f_i_l_e] + Use a lesskey file. + -K ........ --quit-on-intr + Exit less in response to ctrl-C. + -L ........ --no-lessopen + Ignore the LESSOPEN environment variable. + -m -M .... --long-prompt --LONG-PROMPT + Set prompt style. + -n -N .... --line-numbers --LINE-NUMBERS + Don't use line numbers. + -o [_f_i_l_e] . --log-file=[_f_i_l_e] + Copy to log file (standard input only). + -O [_f_i_l_e] . --LOG-FILE=[_f_i_l_e] + Copy to log file (unconditionally overwrite). + -p [_p_a_t_t_e_r_n] --pattern=[_p_a_t_t_e_r_n] + Start at pattern (from command line). + -P [_p_r_o_m_p_t] --prompt=[_p_r_o_m_p_t] + Define new prompt. + -q -Q .... --quiet --QUIET --silent --SILENT + Quiet the terminal bell. + -r -R .... --raw-control-chars --RAW-CONTROL-CHARS + Output "raw" control characters. + -s ........ --squeeze-blank-lines + Squeeze multiple blank lines. + -S ........ --chop-long-lines + Chop (truncate) long lines rather than wrapping. + -t [_t_a_g] .. --tag=[_t_a_g] + Find a tag. + -T [_t_a_g_s_f_i_l_e] --tag-file=[_t_a_g_s_f_i_l_e] + Use an alternate tags file. + -u -U .... --underline-special --UNDERLINE-SPECIAL + Change handling of backspaces. + -V ........ --version + Display the version number of "less". + -w ........ --hilite-unread + Highlight first new line after forward-screen. + -W ........ --HILITE-UNREAD + Highlight first new line after any forward movement. + -x [_N[,...]] --tabs=[_N[,...]] + Set tab stops. + -X ........ --no-init + Don't use termcap init/deinit strings. + -y [_N] .... --max-forw-scroll=[_N] + Forward scroll limit. + -z [_N] .... --window=[_N] + Set size of window. + -" [_c[_c]] . --quotes=[_c[_c]] + Set shell quote characters. + -~ ........ --tilde + Don't display tildes after end of file. + -# [_N] .... --shift=[_N] + Set horizontal scroll amount (0 = one half screen width). + --file-size + Automatically determine the size of the input file. + --follow-name + The F command changes files if the input file is renamed. + --incsearch + Search file as each pattern character is typed in. + --line-num-width=N + Set the width of the -N line number field to N characters. + --mouse + Enable mouse input. + --no-keypad + Don't send termcap keypad init/deinit strings. + --no-histdups + Remove duplicates from command history. + --rscroll=C + Set the character used to mark truncated lines. + --save-marks + Retain marks across invocations of less. + --status-col-width=N + Set the width of the -J status column to N characters. + --use-backslash + Subsequent options use backslash as escape char. + --use-color + Enables colored text. + --wheel-lines=N + Each click of the mouse wheel moves N lines. + + + --------------------------------------------------------------------------- + + LLIINNEE EEDDIITTIINNGG + + These keys can be used to edit text being entered + on the "command line" at the bottom of the screen. + + RightArrow ..................... ESC-l ... Move cursor right one character. + LeftArrow ...................... ESC-h ... Move cursor left one character. + ctrl-RightArrow ESC-RightArrow ESC-w ... Move cursor right one word. + ctrl-LeftArrow ESC-LeftArrow ESC-b ... Move cursor left one word. + HOME ........................... ESC-0 ... Move cursor to start of line. + END ............................ ESC-$ ... Move cursor to end of line. + BACKSPACE ................................ Delete char to left of cursor. + DELETE ......................... ESC-x ... Delete char under cursor. + ctrl-BACKSPACE ESC-BACKSPACE ........... Delete word to left of cursor. + ctrl-DELETE .... ESC-DELETE .... ESC-X ... Delete word under cursor. + ctrl-U ......... ESC (MS-DOS only) ....... Delete entire line. + UpArrow ........................ ESC-k ... Retrieve previous command line. + DownArrow ...................... ESC-j ... Retrieve next command line. + TAB ...................................... Complete filename & cycle. + SHIFT-TAB ...................... ESC-TAB Complete filename & reverse cycle. + ctrl-L ................................... Complete filename, list all. diff --git a/testdata/baselines/reference/submodule/conformance/returnStatementNoAsiAfterTransform(target=es5).js b/testdata/baselines/reference/submodule/conformance/returnStatementNoAsiAfterTransform(target=es5).js index af3c2fde4a..4591b1fd05 100644 --- a/testdata/baselines/reference/submodule/conformance/returnStatementNoAsiAfterTransform(target=es5).js +++ b/testdata/baselines/reference/submodule/conformance/returnStatementNoAsiAfterTransform(target=es5).js @@ -67,52 +67,52 @@ function t10() { //// [returnStatementNoAsiAfterTransform.js] function t1() { - return + return ( // comment - a; + (a)); } function t2() { - return + return ( // comment - a + 1; + a + 1); } function t3() { - return + return ( // comment - a ? 0 : 1; + a ? 0 : 1); } function t4() { - return + return ( // comment - a.b; + a.b); } function t5() { - return + return ( // comment - a[a]; + a[a]); } function t6() { - return + return ( // comment - a(); + a()); } function t7() { - return + return ( // comment - a ``; + a ``); } function t8() { - return + return ( // comment - a; + (a)); } function t9() { - return + return ( // comment - a; + (a)); } function t10() { - return + return ( // comment - a; + (a)); } diff --git a/testdata/baselines/reference/submodule/conformance/returnStatementNoAsiAfterTransform(target=es5).js.diff b/testdata/baselines/reference/submodule/conformance/returnStatementNoAsiAfterTransform(target=es5).js.diff index 531a57c9ef..a7994d0026 100644 --- a/testdata/baselines/reference/submodule/conformance/returnStatementNoAsiAfterTransform(target=es5).js.diff +++ b/testdata/baselines/reference/submodule/conformance/returnStatementNoAsiAfterTransform(target=es5).js.diff @@ -9,72 +9,62 @@ - return cooked; -}; function t1() { -- return ( -+ return + return ( // comment - a); -+ a; ++ (a)); } function t2() { -- return ( -+ return + return ( // comment - a) + 1; -+ a + 1; ++ a + 1); } function t3() { -- return ( -+ return + return ( // comment - a) ? 0 : 1; -+ a ? 0 : 1; ++ a ? 0 : 1); } function t4() { -- return ( -+ return + return ( // comment - a).b; -+ a.b; ++ a.b); } function t5() { -- return ( -+ return + return ( // comment - a)[a]; -+ a[a]; ++ a[a]); } function t6() { -- return ( -+ return + return ( // comment - a)(); -+ a(); ++ a()); } function t7() { -- return ( -+ return + return ( // comment - a)(__makeTemplateObject([""], [""])); -+ a ``; ++ a ``); } function t8() { -- return ( -+ return + return ( // comment - a); -+ a; ++ (a)); } function t9() { -- return ( -+ return + return ( // comment - a); -+ a; ++ (a)); } function t10() { -- return ( -+ return + return ( // comment - a); -+ a; ++ (a)); } \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/returnStatementNoAsiAfterTransform(target=esnext).js b/testdata/baselines/reference/submodule/conformance/returnStatementNoAsiAfterTransform(target=esnext).js index af3c2fde4a..4591b1fd05 100644 --- a/testdata/baselines/reference/submodule/conformance/returnStatementNoAsiAfterTransform(target=esnext).js +++ b/testdata/baselines/reference/submodule/conformance/returnStatementNoAsiAfterTransform(target=esnext).js @@ -67,52 +67,52 @@ function t10() { //// [returnStatementNoAsiAfterTransform.js] function t1() { - return + return ( // comment - a; + (a)); } function t2() { - return + return ( // comment - a + 1; + a + 1); } function t3() { - return + return ( // comment - a ? 0 : 1; + a ? 0 : 1); } function t4() { - return + return ( // comment - a.b; + a.b); } function t5() { - return + return ( // comment - a[a]; + a[a]); } function t6() { - return + return ( // comment - a(); + a()); } function t7() { - return + return ( // comment - a ``; + a ``); } function t8() { - return + return ( // comment - a; + (a)); } function t9() { - return + return ( // comment - a; + (a)); } function t10() { - return + return ( // comment - a; + (a)); } diff --git a/testdata/baselines/reference/submodule/conformance/returnStatementNoAsiAfterTransform(target=esnext).js.diff b/testdata/baselines/reference/submodule/conformance/returnStatementNoAsiAfterTransform(target=esnext).js.diff index b5a0ca9fd6..814cb905eb 100644 --- a/testdata/baselines/reference/submodule/conformance/returnStatementNoAsiAfterTransform(target=esnext).js.diff +++ b/testdata/baselines/reference/submodule/conformance/returnStatementNoAsiAfterTransform(target=esnext).js.diff @@ -1,75 +1,63 @@ --- old.returnStatementNoAsiAfterTransform(target=esnext).js +++ new.returnStatementNoAsiAfterTransform(target=esnext).js -@@= skipped -66, +66 lines =@@ - - //// [returnStatementNoAsiAfterTransform.js] +@@= skipped -68, +68 lines =@@ function t1() { -- return ( -+ return + return ( // comment - a); -+ a; ++ (a)); } function t2() { -- return ( -+ return + return ( // comment - a) + 1; -+ a + 1; ++ a + 1); } function t3() { -- return ( -+ return + return ( // comment - a) ? 0 : 1; -+ a ? 0 : 1; ++ a ? 0 : 1); } function t4() { -- return ( -+ return + return ( // comment - a).b; -+ a.b; ++ a.b); } function t5() { -- return ( -+ return + return ( // comment - a)[a]; -+ a[a]; ++ a[a]); } function t6() { -- return ( -+ return + return ( // comment - a)(); -+ a(); ++ a()); } function t7() { -- return ( -+ return + return ( // comment - a) ``; -+ a ``; ++ a ``); } function t8() { -- return ( -+ return + return ( // comment - a); -+ a; ++ (a)); } function t9() { -- return ( -+ return + return ( // comment - a); -+ a; ++ (a)); } function t10() { -- return ( -+ return + return ( // comment - a); -+ a; ++ (a)); } \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/yieldStatementNoAsiAfterTransform(target=es5).js b/testdata/baselines/reference/submodule/conformance/yieldStatementNoAsiAfterTransform(target=es5).js index c0af9e05dd..cc3360cec9 100644 --- a/testdata/baselines/reference/submodule/conformance/yieldStatementNoAsiAfterTransform(target=es5).js +++ b/testdata/baselines/reference/submodule/conformance/yieldStatementNoAsiAfterTransform(target=es5).js @@ -67,52 +67,52 @@ function *t10() { //// [yieldStatementNoAsiAfterTransform.js] function* t1() { - yield + yield ( // comment - a; + (a)); } function* t2() { - yield + yield ( // comment - a + 1; + a + 1); } function* t3() { - yield + yield ( // comment - a ? 0 : 1; + a ? 0 : 1); } function* t4() { - yield + yield ( // comment - a.b; + a.b); } function* t5() { - yield + yield ( // comment - a[a]; + a[a]); } function* t6() { - yield + yield ( // comment - a(); + a()); } function* t7() { - yield + yield ( // comment - a ``; + a ``); } function* t8() { - yield + yield ( // comment - a; + (a)); } function* t9() { - yield + yield ( // comment - a; + (a)); } function* t10() { - yield + yield ( // comment - a; + (a)); } diff --git a/testdata/baselines/reference/submodule/conformance/yieldStatementNoAsiAfterTransform(target=es5).js.diff b/testdata/baselines/reference/submodule/conformance/yieldStatementNoAsiAfterTransform(target=es5).js.diff index 3af252235d..b7b3a895c0 100644 --- a/testdata/baselines/reference/submodule/conformance/yieldStatementNoAsiAfterTransform(target=es5).js.diff +++ b/testdata/baselines/reference/submodule/conformance/yieldStatementNoAsiAfterTransform(target=es5).js.diff @@ -155,52 +155,52 @@ - } - }); +function* t1() { -+ yield ++ yield ( + // comment -+ a; ++ (a)); +} +function* t2() { -+ yield ++ yield ( + // comment -+ a + 1; ++ a + 1); +} +function* t3() { -+ yield ++ yield ( + // comment -+ a ? 0 : 1; ++ a ? 0 : 1); +} +function* t4() { -+ yield ++ yield ( + // comment -+ a.b; ++ a.b); +} +function* t5() { -+ yield ++ yield ( + // comment -+ a[a]; ++ a[a]); +} +function* t6() { -+ yield ++ yield ( + // comment -+ a(); ++ a()); +} +function* t7() { -+ yield ++ yield ( + // comment -+ a ``; ++ a ``); +} +function* t8() { -+ yield ++ yield ( + // comment -+ a; ++ (a)); +} +function* t9() { -+ yield ++ yield ( + // comment -+ a; ++ (a)); +} +function* t10() { -+ yield ++ yield ( + // comment -+ a; ++ (a)); } \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/yieldStatementNoAsiAfterTransform(target=esnext).js b/testdata/baselines/reference/submodule/conformance/yieldStatementNoAsiAfterTransform(target=esnext).js index c0af9e05dd..cc3360cec9 100644 --- a/testdata/baselines/reference/submodule/conformance/yieldStatementNoAsiAfterTransform(target=esnext).js +++ b/testdata/baselines/reference/submodule/conformance/yieldStatementNoAsiAfterTransform(target=esnext).js @@ -67,52 +67,52 @@ function *t10() { //// [yieldStatementNoAsiAfterTransform.js] function* t1() { - yield + yield ( // comment - a; + (a)); } function* t2() { - yield + yield ( // comment - a + 1; + a + 1); } function* t3() { - yield + yield ( // comment - a ? 0 : 1; + a ? 0 : 1); } function* t4() { - yield + yield ( // comment - a.b; + a.b); } function* t5() { - yield + yield ( // comment - a[a]; + a[a]); } function* t6() { - yield + yield ( // comment - a(); + a()); } function* t7() { - yield + yield ( // comment - a ``; + a ``); } function* t8() { - yield + yield ( // comment - a; + (a)); } function* t9() { - yield + yield ( // comment - a; + (a)); } function* t10() { - yield + yield ( // comment - a; + (a)); } diff --git a/testdata/baselines/reference/submodule/conformance/yieldStatementNoAsiAfterTransform(target=esnext).js.diff b/testdata/baselines/reference/submodule/conformance/yieldStatementNoAsiAfterTransform(target=esnext).js.diff index 1cd1217449..6c55cf9877 100644 --- a/testdata/baselines/reference/submodule/conformance/yieldStatementNoAsiAfterTransform(target=esnext).js.diff +++ b/testdata/baselines/reference/submodule/conformance/yieldStatementNoAsiAfterTransform(target=esnext).js.diff @@ -1,75 +1,63 @@ --- old.yieldStatementNoAsiAfterTransform(target=esnext).js +++ new.yieldStatementNoAsiAfterTransform(target=esnext).js -@@= skipped -66, +66 lines =@@ - - //// [yieldStatementNoAsiAfterTransform.js] +@@= skipped -68, +68 lines =@@ function* t1() { -- yield ( -+ yield + yield ( // comment - a); -+ a; ++ (a)); } function* t2() { -- yield ( -+ yield + yield ( // comment - a) + 1; -+ a + 1; ++ a + 1); } function* t3() { -- yield ( -+ yield + yield ( // comment - a) ? 0 : 1; -+ a ? 0 : 1; ++ a ? 0 : 1); } function* t4() { -- yield ( -+ yield + yield ( // comment - a).b; -+ a.b; ++ a.b); } function* t5() { -- yield ( -+ yield + yield ( // comment - a)[a]; -+ a[a]; ++ a[a]); } function* t6() { -- yield ( -+ yield + yield ( // comment - a)(); -+ a(); ++ a()); } function* t7() { -- yield ( -+ yield + yield ( // comment - a) ``; -+ a ``; ++ a ``); } function* t8() { -- yield ( -+ yield + yield ( // comment - a); -+ a; ++ (a)); } function* t9() { -- yield ( -+ yield + yield ( // comment - a); -+ a; ++ (a)); } function* t10() { -- yield ( -+ yield + yield ( // comment - a); -+ a; ++ (a)); } \ No newline at end of file