Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add support for default code editor (Zed) #5142

Merged
merged 15 commits into from
Oct 15, 2024

Conversation

xxxoooxoxo
Copy link
Contributor

@xxxoooxoxo xxxoooxoxo commented Oct 15, 2024

Implemented the ability to select default code editor #5038. This currently works for both VSCode & Zed.

☕️ Reasoning

Centralized the editor logic (effectively nullifying the use of editor store in favor of userSettings.

This can be extended to allow GitButler to select a default code editor. This is a global setting which can be found in Appearance -> Default Code Editor

Can be used to extend to other default editors, so long as the file path matches that of VSCode

🧢 Changes

  • Editor defaults to userSettings option
  • userSettings.defaultCodeEditor selectable in Appearance -> Default Code Editor
  • Refactored UI to read as generic code editor, replacing the default Open in VSCode
  • Added Zed url scheme in open.rs
gitbutler-fork.mp4

Copy link

vercel bot commented Oct 15, 2024

@xxxoooxoxo is attempting to deploy a commit to the GitButler Team on Vercel.

A member of the Team first needs to authorize it.

@github-actions github-actions bot added rust Pull requests that update Rust code @gitbutler/desktop labels Oct 15, 2024
@Byron
Copy link
Collaborator

Byron commented Oct 15, 2024

Thanks so much for this contribution!

Even though I am unable to evaluate any of the frontend changes, I thought that in order to be equivalent to the previous implementation, it should should keep mentioning the editor in Open in <Editor> instead of generalizing it to Open in Editor.

@xxxoooxoxo
Copy link
Contributor Author

xxxoooxoxo commented Oct 15, 2024

@Byron

Added "Open in <Editor>". Definitely feels more flushed out like that. Thanks!

@krlvi
Copy link
Member

krlvi commented Oct 15, 2024

Thank you for this contribution @xxxoooxoxo! i recently started using zed and have been thinking how much i miss an "open in zed" functionality.
Seem like there is a lint error, other than that this is very much ready to merge

@krlvi
Copy link
Member

krlvi commented Oct 15, 2024

Heres a patch fixing the lint errors. Alternatively you can run pnpm globallint --fix

From 38417e52097195b12862ea8f0e5eb841d0572997 Mon Sep 17 00:00:00 2001
From: Kiril Videlov <[email protected]>
Date: Tue, 15 Oct 2024 20:47:11 +0200
Subject: [PATCH] fix lint errors

---
 .../src/lib/barmenuActions/ProjectSettingsMenuAction.svelte  | 4 ++--
 apps/desktop/src/lib/components/BoardEmptyState.svelte       | 2 +-
 apps/desktop/src/lib/components/EditMode.svelte              | 5 ++---
 apps/desktop/src/lib/file/FileContextMenu.svelte             | 3 +--
 apps/desktop/src/routes/settings/appearance/+page.svelte     | 4 ++--
 5 files changed, 8 insertions(+), 10 deletions(-)

diff --git a/apps/desktop/src/lib/barmenuActions/ProjectSettingsMenuAction.svelte b/apps/desktop/src/lib/barmenuActions/ProjectSettingsMenuAction.svelte
index 5985e84c6..ee2a194c4 100644
--- a/apps/desktop/src/lib/barmenuActions/ProjectSettingsMenuAction.svelte
+++ b/apps/desktop/src/lib/barmenuActions/ProjectSettingsMenuAction.svelte
@@ -2,15 +2,15 @@
 	import { listen } from '$lib/backend/ipc';
 	import { Project } from '$lib/backend/projects';
 	import { showHistoryView } from '$lib/config/config';
-	import { getContextStoreBySymbol } from '@gitbutler/shared/context';
 	import { SETTINGS, type Settings } from '$lib/settings/userSettings';
 	import * as events from '$lib/utils/events';
 	import { unsubscribe } from '$lib/utils/unsubscribe';
 	import { openExternalUrl } from '$lib/utils/url';
+	import { getContextStoreBySymbol } from '@gitbutler/shared/context';
 	import { getContext } from '@gitbutler/shared/context';
 	import { onMount } from 'svelte';
-	import { goto } from '$app/navigation';
 	import type { Writable } from 'svelte/store';
+	import { goto } from '$app/navigation';
 
 	const project = getContext(Project);
 	const userSettings = getContextStoreBySymbol<Settings, Writable<Settings>>(SETTINGS);
diff --git a/apps/desktop/src/lib/components/BoardEmptyState.svelte b/apps/desktop/src/lib/components/BoardEmptyState.svelte
index ddea0e1bf..0caef914e 100644
--- a/apps/desktop/src/lib/components/BoardEmptyState.svelte
+++ b/apps/desktop/src/lib/components/BoardEmptyState.svelte
@@ -2,8 +2,8 @@
 	import zenSvg from '$lib/assets/dzen-pc.svg?raw';
 	import { Project } from '$lib/backend/projects';
 	import { BaseBranch } from '$lib/baseBranch/baseBranch';
-	import { SETTINGS, type Settings } from '$lib/settings/userSettings';
 	import { getGitHost } from '$lib/gitHost/interface/gitHost';
+	import { SETTINGS, type Settings } from '$lib/settings/userSettings';
 	import { openExternalUrl } from '$lib/utils/url';
 	import { BranchController } from '$lib/vbranches/branchController';
 	import { getContext, getContextStore, getContextStoreBySymbol } from '@gitbutler/shared/context';
diff --git a/apps/desktop/src/lib/components/EditMode.svelte b/apps/desktop/src/lib/components/EditMode.svelte
index bdbc68246..d5c9ad71c 100644
--- a/apps/desktop/src/lib/components/EditMode.svelte
+++ b/apps/desktop/src/lib/components/EditMode.svelte
@@ -2,15 +2,14 @@
 	import { Project } from '$lib/backend/projects';
 	import { CommitService } from '$lib/commits/service';
 	import { conflictEntryHint, type ConflictEntryPresence } from '$lib/conflictEntryPresence';
-	import { SETTINGS, type Settings } from '$lib/settings/userSettings';
-	import { getContextStoreBySymbol } from '@gitbutler/shared/context';
-
 	import FileContextMenu from '$lib/file/FileContextMenu.svelte';
 	import { ModeService, type EditModeMetadata } from '$lib/modes/service';
 	import ScrollableContainer from '$lib/scroll/ScrollableContainer.svelte';
+	import { SETTINGS, type Settings } from '$lib/settings/userSettings';
 	import { UncommitedFilesWatcher } from '$lib/uncommitedFiles/watcher';
 	import { openExternalUrl } from '$lib/utils/url';
 	import { Commit, type RemoteFile } from '$lib/vbranches/types';
+	import { getContextStoreBySymbol } from '@gitbutler/shared/context';
 	import { getContext } from '@gitbutler/shared/context';
 	import Badge from '@gitbutler/ui/Badge.svelte';
 	import Button from '@gitbutler/ui/Button.svelte';
diff --git a/apps/desktop/src/lib/file/FileContextMenu.svelte b/apps/desktop/src/lib/file/FileContextMenu.svelte
index 510c04cb2..795262a8b 100644
--- a/apps/desktop/src/lib/file/FileContextMenu.svelte
+++ b/apps/desktop/src/lib/file/FileContextMenu.svelte
@@ -3,14 +3,13 @@
 	import ContextMenu from '$lib/components/contextmenu/ContextMenu.svelte';
 	import ContextMenuItem from '$lib/components/contextmenu/ContextMenuItem.svelte';
 	import ContextMenuSection from '$lib/components/contextmenu/ContextMenuSection.svelte';
-	import { getContextStoreBySymbol } from '@gitbutler/shared/context';
 	import { SETTINGS, type Settings } from '$lib/settings/userSettings';
-
 	import { computeFileStatus } from '$lib/utils/fileStatus';
 	import * as toasts from '$lib/utils/toasts';
 	import { openExternalUrl } from '$lib/utils/url';
 	import { BranchController } from '$lib/vbranches/branchController';
 	import { isAnyFile, LocalFile } from '$lib/vbranches/types';
+	import { getContextStoreBySymbol } from '@gitbutler/shared/context';
 	import { getContext } from '@gitbutler/shared/context';
 	import Button from '@gitbutler/ui/Button.svelte';
 	import Modal from '@gitbutler/ui/Modal.svelte';
diff --git a/apps/desktop/src/routes/settings/appearance/+page.svelte b/apps/desktop/src/routes/settings/appearance/+page.svelte
index 27ec500ec..40345bd08 100644
--- a/apps/desktop/src/routes/settings/appearance/+page.svelte
+++ b/apps/desktop/src/routes/settings/appearance/+page.svelte
@@ -3,6 +3,8 @@
 	import { autoSelectBranchNameFeature } from '$lib/config/uiFeatureFlags';
 	import HunkDiff from '$lib/hunk/HunkDiff.svelte';
 	import SettingsPage from '$lib/layout/SettingsPage.svelte';
+	import Select from '$lib/select/Select.svelte';
+	import SelectItem from '$lib/select/SelectItem.svelte';
 	import ThemeSelector from '$lib/settings/ThemeSelector.svelte';
 	import {
 		SETTINGS,
@@ -17,8 +19,6 @@
 	import { getContextStoreBySymbol } from '@gitbutler/shared/context';
 	import type { ContentSection } from '$lib/utils/fileSections';
 	import type { Writable } from 'svelte/store';
-	import Select from '$lib/select/Select.svelte';
-	import SelectItem from '$lib/select/SelectItem.svelte';
 
 	const editorOptions: CodeEditorSettings[] = [
 		{ schemeIdentifer: 'vscode', displayName: 'VSCode' },
-- 
2.44.0

@krlvi krlvi merged commit e4294d0 into gitbutlerapp:master Oct 15, 2024
16 of 17 checks passed
@krlvi krlvi mentioned this pull request Oct 17, 2024
@Caleb-T-Owens
Copy link
Contributor

This seems like a downgrade because its no longer using "get_editor_link_scheme" from the rust side, which would conditionally open either vscodium or vscode. As such, the "Open in VSCode" button no longer works for me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@gitbutler/desktop rust Pull requests that update Rust code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants