davraamides / todotxt-mode

MIT License
59 stars 12 forks source link

cant redo in python, cpp or source files #23

Closed tyoc213 closed 2 years ago

tyoc213 commented 3 years ago

It seems that the shortcut ctrl+shift+z is always active, doesnt matter if inside or not from a todo.txt, pending.txt or any of the other files, it thinks all files, even .py and other source files as todo files.

davraamides commented 3 years ago

You should be able to restrict this with a "when" clause in the User keybindings.json file like below. But you'll need to delete the Default binding first or it will still be in effect. I'm not aware of a way to do this in general to match the todotxtmode.todoFilename setting since you'd need to reference a variable.

{ "key": "ctrl+shift+z", "command": "extension.decrementPriority", "when": "resourceFilename == 'todo.txt'" }

On Thu, Jan 7, 2021 at 7:39 PM tyoc213 notifications@github.com wrote:

It seems that the shortcut ctrl+shift+z is always active, doesnt matter if inside or not from a todo.txt, pending.txt or any of the other files, it thinks all files, even .py and other source files as todo files.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/davraamides/todotxt-mode/issues/23, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAOOZGIGNFTO256QHWU2FR3SYZH2ZANCNFSM4VZXUYHQ .

tyoc213 commented 3 years ago

From where I can open this file?

image

davraamides commented 3 years ago

You can open it with: View->Open Command Pallette and then select "Preferences: Open Keyboard Shortcuts (JSON)"

On Fri, Jan 8, 2021 at 2:03 PM tyoc213 notifications@github.com wrote:

From where I can open this file?

[image: image] https://user-images.githubusercontent.com/506234/104053971-cf112280-51b1-11eb-92d9-3d32d0108d8e.png

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/davraamides/todotxt-mode/issues/23#issuecomment-756939688, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAOOZGPEVLSC7AAYWKZUSZDSY5JGZANCNFSM4VZXUYHQ .

tyoc213 commented 3 years ago

Found it in the default json

image

But could only edit from File->preferences->Keyboard short cuts or Ctrl+k Ctrl+s

image

You need to right click then "edit when"

Here is my current expression resourceFilename == 'done.txt' || resourceFilename == 'someday.txt' || resourceFilename == 'todo.txt' || resourceFilename == 'waiting.txt'

sjwo commented 2 years ago

I've tried to follow the suggestion above, but the todotxt-mode extension Ctrl-Shift-Z keybinding is still active outside of the specified files.

Here is what my ~/.config/Code/User/keybindings.json looks like:

// Place your key bindings in this file to override the defaults
[
    {
        "key": "ctrl+shift+z",
        "command": "extension.decrementPriority",
        "when": "resourceFilename == 'done.txt' || resourceFilename == 'someday.txt' || resourceFilename == 'todo.txt' || resourceFilename == 'waiting.txt'"
    }
]

I've tried reloading the window.

davraamides commented 2 years ago

There is probably a default binding that is still in effect. Go to Code -> Preferences -> Keyboard Shortcuts and filter for "priority". If you see bindings with Source "Extension" that are conflicting, right-click and select Remove Keybinding, leaving just the User binding with the "when" clause.

sjwo commented 2 years ago

That did the trick! Thank you!

For reference, I'm attaching before and after screenshots.

Before

image

After

image

Thoughts

davraamides commented 2 years ago

I agree that it's a bit backwards that the user settings don't override the global ones. I'm going to look into defining the shortcuts in the extension so they include the "when" clause but it's tricky since people can change the default names of the various todo files.

o-alquimista commented 7 months ago

Using a regular expression to match all files that end in todo.txt:

[
    {
        "key": "ctrl+shift+z",
        "command": "extension.decrementPriority",
        "when": "editorTextFocus && resourceFilename =~ /todo.txt$/"
    },
    {
        "key": "ctrl+shift+z",
        "command": "-extension.decrementPriority",
        "when": "editorTextFocus"
    }
]

@davraamides What do you think? I believe this could become the default.