| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 9d02960 commit 467dbd3
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1735,6 +1735,10 @@ function findExpressionCompleteTarget(code) { | |||
| 1735 | 1735 | // what we can potentially complete on, so let's re-run the function's logic on that | |
| 1736 | 1736 | if (lastBodyStatement.type === 'VariableDeclaration') { | |
| 1737 | 1737 | const lastDeclarationInit = lastBodyStatement.declarations.at(-1).init; | |
| 1738 | + if (!lastDeclarationInit) { | ||
| 1739 | + // If there is no initialization we can simply return | ||
| 1740 | + return null; | ||
| 1741 | + } | ||
| 1738 | 1742 | const lastDeclarationInitCode = code.slice(lastDeclarationInit.start, lastDeclarationInit.end); | |
| 1739 | 1743 | return findExpressionCompleteTarget(lastDeclarationInitCode); | |
| 1740 | 1744 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -50,6 +50,12 @@ function prepareREPL() { | |||
| 50 | 50 | } | |
| 51 | 51 | ||
| 52 | 52 | describe('REPL tab completion (core functionality)', () => { | |
| 53 | + it('does not break with variable declarations without an initialization', () => { | ||
| 54 | + const { replServer } = prepareREPL(); | ||
| 55 | + replServer.complete('let a', getNoResultsFunction()); | ||
| 56 | + replServer.close(); | ||
| 57 | + }); | ||
| 58 | + | ||
| 53 | 59 | it('does not break in an object literal', () => { | |
| 54 | 60 | const { replServer, input } = prepareREPL(); | |
| 55 | 61 | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments