Option to not remember search on startup

On launch the app takes a little time and loads results for the last search term, if there was one.
I’d like this to be optional as I don’t rely on this feature, and I find the animations of new results popping up right as I open the app distracting. The animations, file processing, and facing my irrelevant past searches is something I’d like to avoid.

1 Like

I’d like to see this feature also, since I will improve my start up time. Since I have a large vault, the ‘search on startup’ adds around 6 seconds to Obsidian’s startup time. (Which is of course nothing in the grand scheme, but still. :slightly_smiling_face:)

Plugins load in a non-deterministic order, so you can’t stop loading searches that early, but early enough. More consistent solutions should override the saving the search part instead.
That said, I only found solutions in a plugin’s onload function. These might look a bit janky, but are barely noticable most of the time.

This one clicks the clear search button, then refocuses.

this.app.workspace.onLayoutReady(() => {
	const focused = document.activeElement;
	const clickEvent = new MouseEvent("click", {
		view: window,
		bubbles: true,
		cancelable: false,
	});
	const bt = document.getElementsByClassName("search-input-clear-button")[0];
	bt.dispatchEvent(clickEvent);
	(focused as HTMLElement).focus();
});

This one loads a workspace using the core plugin, thus overriding your layout.

this.app.workspace.onLayoutReady(() => {
	const workspaces = (this.app as any)?.internalPlugins?.plugins?.workspaces;
	if (!workspaces) {
		new Notice("Cannot find Workspaces plugin. Please file an issue.");
	} else if (workspaces.enabled) {
		workspaces.instance.loadWorkspace("my shit");
	} else {
		new Notice("Workspaces plugin is not enabled");
	}
});