mirror of
https://github.com/aljazceru/opencode.git
synced 2025-12-22 10:14:22 +01:00
fix: unshare command missing
This commit is contained in:
@@ -2,6 +2,7 @@ package commands
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
"log/slog"
|
||||||
"slices"
|
"slices"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
@@ -155,6 +156,9 @@ func (k Command) Matches(msg tea.KeyPressMsg, leader bool) bool {
|
|||||||
func parseBindings(bindings ...string) []Keybinding {
|
func parseBindings(bindings ...string) []Keybinding {
|
||||||
var parsedBindings []Keybinding
|
var parsedBindings []Keybinding
|
||||||
for _, binding := range bindings {
|
for _, binding := range bindings {
|
||||||
|
if binding == "none" {
|
||||||
|
continue
|
||||||
|
}
|
||||||
for p := range strings.SplitSeq(binding, ",") {
|
for p := range strings.SplitSeq(binding, ",") {
|
||||||
requireLeader := strings.HasPrefix(p, "<leader>")
|
requireLeader := strings.HasPrefix(p, "<leader>")
|
||||||
keybinding := strings.ReplaceAll(p, "<leader>", "")
|
keybinding := strings.ReplaceAll(p, "<leader>", "")
|
||||||
@@ -219,7 +223,6 @@ func LoadFromConfig(config *opencode.Config) CommandRegistry {
|
|||||||
{
|
{
|
||||||
Name: SessionUnshareCommand,
|
Name: SessionUnshareCommand,
|
||||||
Description: "unshare session",
|
Description: "unshare session",
|
||||||
Keybindings: parseBindings("<leader>u"),
|
|
||||||
Trigger: []string{"unshare"},
|
Trigger: []string{"unshare"},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -375,15 +378,14 @@ func LoadFromConfig(config *opencode.Config) CommandRegistry {
|
|||||||
// Remove share/unshare commands if sharing is disabled
|
// Remove share/unshare commands if sharing is disabled
|
||||||
if config.Share == opencode.ConfigShareDisabled &&
|
if config.Share == opencode.ConfigShareDisabled &&
|
||||||
(command.Name == SessionShareCommand || command.Name == SessionUnshareCommand) {
|
(command.Name == SessionShareCommand || command.Name == SessionUnshareCommand) {
|
||||||
|
slog.Info("Removing share/unshare commands")
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if keybind, ok := keybinds[string(command.Name)]; ok && keybind != "" {
|
if keybind, ok := keybinds[string(command.Name)]; ok && keybind != "" {
|
||||||
if keybind == "none" {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
command.Keybindings = parseBindings(keybind)
|
command.Keybindings = parseBindings(keybind)
|
||||||
}
|
}
|
||||||
registry[command.Name] = command
|
registry[command.Name] = command
|
||||||
}
|
}
|
||||||
|
slog.Info("Loaded commands", "commands", registry)
|
||||||
return registry
|
return registry
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user