Skip to content

Conversation

@EmilyGraceSeville7cf
Copy link

@EmilyGraceSeville7cf EmilyGraceSeville7cf commented May 22, 2023

Notes

  • duplicating keys are prohibited, like alt-alt

image

image

Questions

image

Are they correct (but still not documented here) or invalid? I see editor:insert_last_word_previous_command appears in docs. Is FORMAT.md just outdated?

@EmilyGraceSeville7cf EmilyGraceSeville7cf changed the title feat(schema): intellisence for keybindings Feature/json schema for keybindings May 22, 2023
Copy link

@davidmelvin davidmelvin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi! Thanks very much for this suggestion! I think it's a great improvement on what we have! :)

Do you think you could update the README with simple instructions as to where users should put the new .vscode/settings.json and schemas/keybindings.json files, that they will need to install an extension like redhat.vscode-yaml to see the Intellisense?

"type": "string",
"minLength": 1,
"not": {
"pattern": "---|([^-]+)-\\1"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you think you could update the pattern to account for our exact keybinding format? I understand that might be hard to do in regex!

It's important so we don't create a situation where the keyboard shortcuts look good to VS Code, but don't work in Warp.

Copy link
Author

@EmilyGraceSeville7cf EmilyGraceSeville7cf Jun 2, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The issue with comprehensive regex that it will be shown (by YAML Red Hat plugin) when wrong value is passed. And it will look unreadable and hard to figure out what's wrong. :) I think that the best option here is to implement simple plugin which checks format completely and displays possible key combinations. So, yeah, JSON Schema does not always covers everything.

@EmilyGraceSeville7cf
Copy link
Author

Tomorrow I try to finish this PR.

@EmilyGraceSeville7cf
Copy link
Author

EmilyGraceSeville7cf commented Jul 16, 2023

@davidmelvin, I've wrote a script to extract all shortcuts as JSON (just properties contents is returned as output.json file, not full JSON schema):

#!/usr/bin/env bash

to_css_path() {
    declare in_number="$1"

    declare prefix='/html/body/div[1]/div/div/div[2]/div/div[2]/div/div/main/div[2]/div[1]/div/'
    declare suffix='/div/div/div/div/div/div/div/div/div/div/div/div/div/table'

    echo "${prefix}div[$in_number]$suffix" |
        sed --regexp-extended 's|/html/body/||' |
        sed --regexp-extended 's|/| > |g' |
        sed --regexp-extended 's|\[(..?)\]|:nth-of-type(\1)|g'
}

get_shortcut_info() {
    declare show_shortcut=false
    declare show_command=false
    declare show_action=false

    declare in_table="$1"
    declare -i in_index="$2"

    declare show_shortcut=false
    declare show_command=false
    declare show_action=false

    shift 2
    while [[ -n $1 ]]; do
        declare flag="$1"
        case "$flag" in
            --shortcut|-s)
                show_shortcut=true
                ;;
            --command|-c)
                show_command=true
                ;;
            --action|-a)
                show_action=true
                ;;
        esac
        shift
    done

    [[ $show_shortcut == true ]] &&
        yq --input-format xml ".table.tbody.tr[$in_index].td[0].div.div.div.div.div.span.code.+content" <(echo "$in_table") 2> /dev/null
    [[ $show_command == true ]] &&
        yq --input-format xml ".table.tbody.tr[$in_index].td[1].div.div.div.div.div.span.span.+content" <(echo "$in_table") 2> /dev/null
    [[ $show_action == true ]] &&
        yq --input-format xml ".table.tbody.tr[$in_index].td[2].div.div.div.div.div.span.code.+content" <(echo "$in_table") 2> /dev/null
}

get_shortcut_definition() {
    declare in_shortcut="$1"
    declare in_command="$2"
    declare in_action="$3"

    echo "\"$in_action\": {
    \"title\": \"$in_action\",
    \"description\": \"$(sed --regexp-extended 's/(.)(.*)/\1\L\2/' <<< "$in_command")\",
    \"default\": \"$in_shortcut\",
    \"\$ref\": \"#/definitions/key\"
}"
}

declare tables=()

for item in $(seq 9 17); do
    (( item % 2 == 0 )) && continue
    tables+=("$(pup --file doc.html "$(to_css_path "$item")")")
done

for table in "${tables[@]}"; do
    declare shortcut=
    declare -i index=0
    # shellcheck disable=2155
    while true; do
        declare shortcut="$(get_shortcut_info "$table" "$index" --shortcut)"
        declare command="$(get_shortcut_info "$table" "$index" --command)"
        declare action="$(get_shortcut_info "$table" "$index" --action)"

        [[ "$shortcut" == null ]] && break

        get_shortcut_definition "$shortcut" "$command" "$action"
        echo ,
        index+=1
    done
    
done > output.json

This doc page should be downloaded and saved as doc.html as script searches for this file to get info from.

@EmilyGraceSeville7cf
Copy link
Author

EmilyGraceSeville7cf commented Jul 16, 2023

@davidmelvin, there are two undocumented properties in docs:

  • editor:select_to_line_start
  • editor_view:select_right

@davidmelvin
Copy link

@EmilySeville7cfg thank you!! Will review this soon.

@EmilyGraceSeville7cf
Copy link
Author

@EmilySeville7cfg thank you!! Will review this soon.

What about to review this PR? ;)

@EmilyGraceSeville7cf
Copy link
Author

JSON schemas for Warp are available here now. PR is closed as I didn't get any response from project maintainers in a reasonable time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants