diff --git a/CHANGELOG.md b/CHANGELOG.md index 8e6065b..64e706d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,11 @@ All notable changes to the Databricks Notebook Studio extension will be document The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [0.4.5] - 2026-04-02 + +### Fixed +- **%run and %fs magic commands no longer stripped from notebook cells**: The notebook rendering was incorrectly removing `%run` and `%fs` prefixes from cell content when the notebook change handler fired, treating them as removable magic commands instead of preserving them like `%pip` + ## [0.4.4] - 2026-03-03 ### Fixed diff --git a/package.json b/package.json index 39fd322..0ef36aa 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "databricks-notebook-studio", "displayName": "Databricks Notebook Studio", "description": "Visualize Databricks .py notebooks with rich DataFrame display, interactive tables, column sorting/resizing, and multi-profile authentication", - "version": "0.4.4", + "version": "0.4.5", "license": "MIT", "type": "commonjs", "publisher": "databricks-notebook-studio", diff --git a/src/extension.ts b/src/extension.ts index e7f1bc1..01f29d0 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -534,10 +534,17 @@ async function handleMagicInPythonCell( magic: string, languageId: string ): Promise { - // %pip cells should stay as Python cells (like Jupyter) - don't convert or remove - if (magic === '%pip') { + // %pip, %run, and %fs cells should stay as Python cells - don't convert or remove the magic command. + // These are special Databricks commands that must remain visible in the cell content. + const magicTypeMap: Record = { + '%pip': 'pip', + '%run': 'run', + '%fs': 'fs', + }; + const preservedType = magicTypeMap[magic]; + if (preservedType) { // Only update metadata if not already set to avoid repeated cell replacements - if (cell.metadata?.databricksType !== 'pip') { + if (cell.metadata?.databricksType !== preservedType) { const cellKey = cell.document.uri.toString(); // Skip if already processed if (autoDetectedCells.has(cellKey)) { @@ -549,7 +556,7 @@ async function handleMagicInPythonCell( languageId: 'python', metadata: { ...c.metadata, - databricksType: 'pip', + databricksType: preservedType, }, }), { enterEditMode: true,