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

Add Ctrl+U shortcut #1703

Merged
merged 2 commits into from
Dec 21, 2024
Merged

Conversation

nuckle
Copy link
Contributor

@nuckle nuckle commented Dec 13, 2024

Description

Closes this issue - #1689

Screenshots

Before pressing Ctrl+U Before pressing Ctrl+U
After pressing Ctrl+U After pressing Ctrl+U

Additional information

This shortcut needs to be listed here - https://github.com/JustArchiNET/ASF-ui/wiki/Features#shortcuts

Checklist

  • My pull request is not a duplicate
  • I added a descriptive title to this pull request
  • I added a concise description or a self-explanatory screenshot to this pull request
  • My code follows the code style of this project
  • I have performed a self-review of my own code

@JustArchi JustArchi requested a review from MrBurrBurr December 13, 2024 11:56
Copy link
Member

@Aareksio Aareksio left a comment

Choose a reason for hiding this comment

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

If nextTick works here, I'd use it instead of setTimeout

@nuckle
Copy link
Contributor Author

nuckle commented Dec 13, 2024

Like so?

      jumpToStart() {
        const el = this.$refs['terminal-input'];
        if (el.setSelectionRange) el.setSelectionRange(0, 0);
      },

      deleteBeforeCursorAndJumpToStart() {
        this.removeBeforeCursor();
        this.$nextTick(() => {
          this.jumpToStart();
        })
      },

@Aareksio
Copy link
Member

Aareksio commented Dec 18, 2024

I'd just replace setTimeout with next tick:

if (el.setSelectionRange) {
  this.$nextTick(() => el.setSelectionRange(0, 0));
}

I do not know why you require setTimeout in the first place, but nextTick should achieve similar result

@nuckle
Copy link
Contributor Author

nuckle commented Dec 19, 2024

I'm not sure about this too, but it's required in this case to use setTimeout or nextTick. I decided to use setTimeout, because there's a similar function moveCursorToEnd that uses this. But I agree that nextTrick is a better choice

moveCursorToEnd() {
  const el = this.$refs['terminal-input'];
  const len = this.command.length;

  if (el.setSelectionRange) setTimeout(() => el.setSelectionRange(len, len), 0);
}

@Aareksio
Copy link
Member

Ah right, you followed the pattern. This is good. @MrBurrBurr merge? Apart from fulfilling Botan's request, this looks solid and harmless.

@MrBurrBurr
Copy link
Member

MrBurrBurr commented Dec 20, 2024

I will take a look and see why we are using setTimeout and if we need it or if it could be replaced with nextTick.

Other than that, thank you @nuckle for your contribution - LGTM!

@MrBurrBurr MrBurrBurr merged commit 57b98e6 into JustArchiNET:main Dec 21, 2024
3 checks passed
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.

3 participants