From e9f107113ed9a96842d39b8346917a49fb25288d Mon Sep 17 00:00:00 2001 From: Anthony Kim <62267334+anthonykim1@users.noreply.github.com> Date: Fri, 16 Aug 2024 15:09:46 -0700 Subject: [PATCH] Fix telemetry not getting picked up for Terminal REPL (#23958) https://github.com/microsoft/vscode-python/pull/23941 Having no blank spaces in front of plain 'python' or 'python3' were returning falsey value. --- python_files/Notebooks intro.ipynb | 95 ++++++++++--------- .../codeExecution/terminalReplWatcher.ts | 2 +- 2 files changed, 49 insertions(+), 48 deletions(-) diff --git a/python_files/Notebooks intro.ipynb b/python_files/Notebooks intro.ipynb index 850d7f5a86f9..0e8aadad1919 100644 --- a/python_files/Notebooks intro.ipynb +++ b/python_files/Notebooks intro.ipynb @@ -11,7 +11,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "1. Open the command palette with the shortcut: `Ctrl/Command` + `Shift` + `P`\r\n", + "1. Open the command palette with the shortcut: `Ctrl/Command` + `Shift` + `P`\n", "2. Search for the command `Create New Blank Notebook`" ] }, @@ -26,8 +26,8 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "1. Open the command palette with the shortcut: `Ctrl/Command` + `Shift` + `P`\r\n", - "\r\n", + "1. Open the command palette with the shortcut: `Ctrl/Command` + `Shift` + `P`\n", + "\n", "2. Search for the command `Python: Open Start Page`" ] }, @@ -42,10 +42,10 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "You are currently viewing what we call our Notebook Editor. It is an interactive document based on Jupyter Notebooks that supports the intermixing of code, outputs and markdown documentation. \r\n", - "\r\n", - "This cell is a markdown cell. To edit the text in this cell, simply double click on the cell to change it into edit mode.\r\n", - "\r\n", + "You are currently viewing what we call our Notebook Editor. It is an interactive document based on Jupyter Notebooks that supports the intermixing of code, outputs and markdown documentation. \n", + "\n", + "This cell is a markdown cell. To edit the text in this cell, simply double click on the cell to change it into edit mode.\n", + "\n", "The next cell below is a code cell. You can switch a cell between code and markdown by clicking on the code ![code icon](https://raw.githubusercontent.com/microsoft/vscode-python/main/images/codeIcon.PNG) /markdown ![markdown icon](https://raw.githubusercontent.com/microsoft/vscode-python/main/images/markdownIcon.PNG) icons or using the keyboard shortcut `M` and `Y` respectively." ] }, @@ -55,16 +55,16 @@ "metadata": {}, "outputs": [], "source": [ - "print('hello world')" + "print(\"hello world\")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ - "* To execute the code in the cell above, click on the cell to select it and then either press the play ![play](https://raw.githubusercontent.com/microsoft/vscode-python/main/images/playIcon.PNG) button in the cell toolbar, or use the keyboard shortcut `Ctrl/Command` + `Enter`.\r\n", - "* To edit the code, just click in cell and start editing.\r\n", - "* To add a new cell below, click the `Add Cell` icon ![add cell](https://raw.githubusercontent.com/microsoft/vscode-python/main/images/addIcon.PNG) at the bottom left of the cell or enter command mode with the `ESC` Key and then use the keyboard shortcut `B` to create the new cell below.\r\n" + "* To execute the code in the cell above, click on the cell to select it and then either press the play ![play](https://raw.githubusercontent.com/microsoft/vscode-python/main/images/playIcon.PNG) button in the cell toolbar, or use the keyboard shortcut `Ctrl/Command` + `Enter`.\n", + "* To edit the code, just click in cell and start editing.\n", + "* To add a new cell below, click the `Add Cell` icon ![add cell](https://raw.githubusercontent.com/microsoft/vscode-python/main/images/addIcon.PNG) at the bottom left of the cell or enter command mode with the `ESC` Key and then use the keyboard shortcut `B` to create the new cell below.\n" ] }, { @@ -78,40 +78,40 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "**Variable explorer**\r\n", - "\r\n", - "To view all your active variables and their current values in the notebook, click on the variable explorer icon ![variable explorer](https://raw.githubusercontent.com/microsoft/vscode-python/main/images/variableExplorerIcon.PNG) in the top toolbar.\r\n", - "\r\n", - "![Variable Explorer](https://raw.githubusercontent.com/microsoft/vscode-python/main/images/variableexplorer.png)\r\n", - "\r\n", - "**Data Viewer**\r\n", - "\r\n", - "To view your data frame in a more visual \"Excel\" like format, open the variable explorer and to the left of any dataframe object, you will see the data viewer icon ![data viewer](https://raw.githubusercontent.com/microsoft/vscode-python/main/images/dataViewerIcon.PNG) which you can click to open the data viewer.\r\n", - "\r\n", - "![Data Viewer](https://raw.githubusercontent.com/microsoft/vscode-python/main/images/dataviewer.gif)\r\n", - "\r\n", - "**Convert to Python File**\r\n", - "\r\n", - "To export your notebook to a Python file (.py), click on the `Convert to Python script` icon ![Export icon](https://raw.githubusercontent.com/microsoft/vscode-python/main/images/exportIcon.PNG) in the top toolbar \r\n", - "\r\n", - "![Export](https://raw.githubusercontent.com/microsoft/vscode-python/main/images/savetopythonfile.png)\r\n", - "\r\n", - "**Plot Viewer**\r\n", - "\r\n", - "If you have a graph (such as matplotlib) in your output, you'll notice if you hover over the graph, the `Plot Viewer` icon ![Plot Viewer](https://raw.githubusercontent.com/microsoft/vscode-python/main/images/plotViewerIcon.PNG) will appear in the top left. Click the icon to open up the graph in the Plotviewer which allows you to zoom on your plots and export it in formats such as png and jpeg.\r\n", - "\r\n", - "![Plot Viewer](https://raw.githubusercontent.com/microsoft/vscode-python/main/images/plotviewer.gif)\r\n", - "\r\n", - "**Switching Kernels**\r\n", - "\r\n", - "The notebook editor will detect all kernels in your system by default. To change your notebook kernel, click on the kernel status in the top toolbar at the far right. For example, your kernel status may say \"Python 3: Idle\". This will open up the kernel selector where you can choose your desired kernel.\r\n", - "\r\n", - "![Switching Kernels](https://raw.githubusercontent.com/microsoft/vscode-python/main/images/kernelchange.gif)\r\n", - "\r\n", - "**Remote Jupyter Server**\r\n", - "\r\n", - "To connect to a remote Jupyter server, open the command prompt and search for the command `Specify remote or local Jupyter server for connections`. Then select `Existing` and enter the remote Jupyter server URL. Afterwards, you'll be prompted to reload the window and the Notebook will be opened connected to the remote Jupyter server.\r\n", - "\r\n", + "**Variable explorer**\n", + "\n", + "To view all your active variables and their current values in the notebook, click on the variable explorer icon ![variable explorer](https://raw.githubusercontent.com/microsoft/vscode-python/main/images/variableExplorerIcon.PNG) in the top toolbar.\n", + "\n", + "![Variable Explorer](https://raw.githubusercontent.com/microsoft/vscode-python/main/images/variableexplorer.png)\n", + "\n", + "**Data Viewer**\n", + "\n", + "To view your data frame in a more visual \"Excel\" like format, open the variable explorer and to the left of any dataframe object, you will see the data viewer icon ![data viewer](https://raw.githubusercontent.com/microsoft/vscode-python/main/images/dataViewerIcon.PNG) which you can click to open the data viewer.\n", + "\n", + "![Data Viewer](https://raw.githubusercontent.com/microsoft/vscode-python/main/images/dataviewer.gif)\n", + "\n", + "**Convert to Python File**\n", + "\n", + "To export your notebook to a Python file (.py), click on the `Convert to Python script` icon ![Export icon](https://raw.githubusercontent.com/microsoft/vscode-python/main/images/exportIcon.PNG) in the top toolbar \n", + "\n", + "![Export](https://raw.githubusercontent.com/microsoft/vscode-python/main/images/savetopythonfile.png)\n", + "\n", + "**Plot Viewer**\n", + "\n", + "If you have a graph (such as matplotlib) in your output, you'll notice if you hover over the graph, the `Plot Viewer` icon ![Plot Viewer](https://raw.githubusercontent.com/microsoft/vscode-python/main/images/plotViewerIcon.PNG) will appear in the top left. Click the icon to open up the graph in the Plotviewer which allows you to zoom on your plots and export it in formats such as png and jpeg.\n", + "\n", + "![Plot Viewer](https://raw.githubusercontent.com/microsoft/vscode-python/main/images/plotviewer.gif)\n", + "\n", + "**Switching Kernels**\n", + "\n", + "The notebook editor will detect all kernels in your system by default. To change your notebook kernel, click on the kernel status in the top toolbar at the far right. For example, your kernel status may say \"Python 3: Idle\". This will open up the kernel selector where you can choose your desired kernel.\n", + "\n", + "![Switching Kernels](https://raw.githubusercontent.com/microsoft/vscode-python/main/images/kernelchange.gif)\n", + "\n", + "**Remote Jupyter Server**\n", + "\n", + "To connect to a remote Jupyter server, open the command prompt and search for the command `Specify remote or local Jupyter server for connections`. Then select `Existing` and enter the remote Jupyter server URL. Afterwards, you'll be prompted to reload the window and the Notebook will be opened connected to the remote Jupyter server.\n", + "\n", "![Remote](https://raw.githubusercontent.com/microsoft/vscode-python/main/images/remoteserver.gif)" ] }, @@ -129,7 +129,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "- [Data science tutorial for Visual Studio Code](https://code.visualstudio.com/docs/python/data-science-tutorial)\r\n", + "- [Data science tutorial for Visual Studio Code](https://code.visualstudio.com/docs/python/data-science-tutorial)\n", "- [Jupyter Notebooks in Visual Studio Code documentation](https://code.visualstudio.com/docs/python/jupyter-support)" ] } @@ -145,9 +145,10 @@ "name": "python3" }, "language_info": { + "name": "python", "version": "3.8.6-final" } }, "nbformat": 4, "nbformat_minor": 0 -} \ No newline at end of file +} diff --git a/src/client/terminals/codeExecution/terminalReplWatcher.ts b/src/client/terminals/codeExecution/terminalReplWatcher.ts index 5921bf8b07c4..dfe89ce1dc87 100644 --- a/src/client/terminals/codeExecution/terminalReplWatcher.ts +++ b/src/client/terminals/codeExecution/terminalReplWatcher.ts @@ -5,7 +5,7 @@ import { EventName } from '../../telemetry/constants'; function checkREPLCommand(command: string): boolean { const lower = command.toLowerCase().trimStart(); - return lower.startsWith('python ') || lower.startsWith('py '); + return lower.startsWith('python') || lower.startsWith('py'); } export function registerTriggerForTerminalREPL(disposables: Disposable[]): void {