Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions marimo/_config/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,10 @@ def language_servers(self) -> LanguageServersConfig:
return self._config["language_servers"]
return {}

@property
def is_auto_save_enabled(self) -> bool:
return self._config["save"]["autosave"] == "after_delay"

@property
def experimental(self) -> ExperimentalConfigType:
if "experimental" in self._config:
Expand Down
15 changes: 2 additions & 13 deletions marimo/_server/start.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,19 +196,8 @@ def start(
min_port=DEFAULT_PORT + 400,
)

# If watch is true, disable auto-save and format-on-save,
# watch is enabled when they are editing in another editor
if watch:
config_reader = config_reader.with_overrides(
{
"save": {
"autosave": "off",
"format_on_save": False,
"autosave_delay": 1000,
}
}
)
LOGGER.info("Watch mode enabled, auto-save is disabled")
if watch and config_reader.is_auto_save_enabled:
LOGGER.warning("Watch mode enabled and may interfere with auto-save.")

if GLOBAL_SETTINGS.MANAGE_SCRIPT_METADATA:
config_reader = config_reader.with_overrides(
Expand Down
24 changes: 5 additions & 19 deletions tests/_server/test_sessions.py
Original file line number Diff line number Diff line change
Expand Up @@ -604,23 +604,14 @@ def __():


@save_and_restore_main
def test_watch_mode_config_override(tmp_path: Path) -> None:
"""Test that watch mode properly overrides config settings."""
def test_watch_mode_does_not_override_config(tmp_path: Path) -> None:
"""Test that watch mode does not override config settings."""
# Create a temporary file
tmp_file = tmp_path / "test_watch_mode_config_override.py"
tmp_file.write_text("import marimo as mo")

# Create a config with autosave enabled
# Create a default config (autosave enabled by default)
config_reader = get_default_config_manager(current_path=None)
config_reader_watch = config_reader.with_overrides(
{
"save": {
"autosave": "off",
"format_on_save": False,
"autosave_delay": 2000,
}
}
)

# Create a session manager with watch mode enabled
file_router = AppFileRouter.from_filename(MarimoPath(str(tmp_file)))
Expand All @@ -631,7 +622,7 @@ def test_watch_mode_config_override(tmp_path: Path) -> None:
quiet=True,
include_code=True,
lsp_server=MagicMock(),
config_manager=config_reader_watch,
config_manager=config_reader,
cli_args={},
argv=None,
auth_token=None,
Expand All @@ -657,13 +648,8 @@ def test_watch_mode_config_override(tmp_path: Path) -> None:
)

try:
# Verify that the config was overridden
# Verify that the config was not overridden for watch mode
config = session_manager._config_manager.get_config()
assert config["save"]["autosave"] == "off"
assert config["save"]["format_on_save"] is False

# Verify that the config was not overridden
config = session_manager_no_watch._config_manager.get_config()
assert config["save"]["autosave"] == "after_delay"
assert config["save"]["format_on_save"] is True

Expand Down
Loading