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

Ctrl-t (transpose) command inserts extra character. #8574

Closed
gwk opened this issue Jun 30, 2016 · 17 comments · Fixed by #45499
Closed

Ctrl-t (transpose) command inserts extra character. #8574

gwk opened this issue Jun 30, 2016 · 17 comments · Fixed by #45499
Assignees
Labels
feature-request Request for new features or functionality macos Issues with VS Code on MAC/OS X verification-needed Verification of issue is requested verified Verification succeeded
Milestone

Comments

@gwk
Copy link

gwk commented Jun 30, 2016

  • VSCode Version:
    Version 1.3.0-insider (1.3.0-insider)
    a21c123
    2016-06-30T05:01:53.185Z
  • OS Version:
    OSX 10.11.5 (15F34)

Steps to Reproduce:

  1. In a new document, type 'ab'.
  2. Place the editor caret between the two characters.
  3. Press ctrl-t.

In any standard OSX text area, this results in the text 'ba'.
In VS Code, the result is 'bab', which I cannot imagine justifying as desirable.

Note that there is a separate behavior when the caret is at end-of-line: in the EOL case, the previous two characters are transposed. VS Code handles this correctly; it is only the "in between" case that is broken (as far as I can tell). Any fix should make sure to test both cases.

@bpasero bpasero added bug Issue identified by VS Code Team member as probable bug editor labels Jun 30, 2016
@alexdima alexdima added the macos Issues with VS Code on MAC/OS X label Jul 12, 2016
@alexdima alexdima added this to the Backlog milestone Jul 12, 2016
@baldmountain
Copy link

I had a look in the source to see if I could fix this since it's driving me nuts. :) I think it may be an Electron issue since I don't see where this editor command is defined. I'm new to the source code so I may be missing it, but I don't see where a command is defined for ctrl-t.

@gwk
Copy link
Author

gwk commented Aug 3, 2016

This seems to have gotten worse recently; occasionally ctrl-t will cause multiple lines of text below the cursor to get duplicated into the text buffer.

@gwk
Copy link
Author

gwk commented Sep 28, 2016

@alexandrudima do you have any idea if the likely source of this bug is in the vscode or electron code bases? I also went hunting around in vscode and could not find anything. I tried downloading an electron tutorial app but could not find a text field in which to test the problem. Any guidance here would be much appreciated.

@gwk
Copy link
Author

gwk commented Sep 28, 2016

For what it's worth the Atom app does not exhibit the broken vscode behavior.

However, Atom's implementation has slightly different behavior than 'traditional' bash and native Cocoa controls. The traditional behavior is to transpose characters before and after the cursor AND move the cursor to after the transposed pair, or if there is no character after the cursor (end-of-line case) then transpose the preceding two characters.

Atom transposes before and after characters around the cursor but does not move them; for the end-of-line case it does no transposition but instead moves the cursor back by one character.

@Zarel
Copy link
Contributor

Zarel commented Oct 13, 2016

I would assume that the solution would be to manually reimplement it, like VSCode already does for ^a ^e ^b ^f ^n ^p

https://marketplace.visualstudio.com/items?itemName=v4run.transpose

This extension does just that.

It'd be nice if the functionality of this extension were bundled, since it's basic functionality that works on every other macOS textbox. The Sublime Text selection transpose is just bonus that's really nice.

@ramya-rao-a
Copy link
Contributor

Verified that when the cursor is in between 2 letters, they get transposed.
But when cursor is at eol, previously last 2 letters were getting transposed. That doesn't happen anymore.

@alexandrudima ?

@alexdima
Copy link
Member

I tried ctrl+t in TextEdit and implemented the behaviour I observed there. Is the behaviour different than what TextEdit does?

@ramya-rao-a
Copy link
Contributor

I was basing my comment off of the OP's

Note that there is a separate behavior when the caret is at end-of-line: in the EOL case, the previous two characters are transposed. VS Code handles this correctly; it is only the "in between" case that is broken (as far as I can tell). Any fix should make sure to test both cases.

@alexdima
Copy link
Member

ctrl+t in the editor now transposes characters like the default mac text editor. IMHO that is a good thing.

@jrieken jrieken added the verified Verification succeeded label Jan 26, 2017
@gwk
Copy link
Author

gwk commented Jan 26, 2017

@alexandrudima sadly it only matches half of the behavior; there are two cases. When I reported this bug I noted that the EOL case worked correctly but the in-between case did not.

Now as of insiders build 6ba4282 it appears that the situation has been reversed. Could we please reopen the issue? Thank you.

@alexdima alexdima reopened this Jan 26, 2017
@alexdima alexdima added feature-request Request for new features or functionality and removed bug Issue identified by VS Code Team member as probable bug verified Verification succeeded labels Jan 26, 2017
@alexdima alexdima modified the milestones: Backlog, January 2017 Jan 26, 2017
@alexdima alexdima removed their assignment Jan 26, 2017
@alexdima alexdima added good first issue Issues identified as good for first-time contributors help wanted Issues identified as good community contribution opportunities labels Jan 26, 2017
@gwk
Copy link
Author

gwk commented Jan 28, 2017

I just noticed that the start-of-line case is also incorrect: TextEdit transposes the newline before the caret with the character after the caret while VSCode simply advances the caret.

@JeremyLoy
Copy link
Contributor

I cannot reproduce this issue. Using VS Code 1.12.1 and default key bindings.

Move to have this issue closed?

@Zarel
Copy link
Contributor

Zarel commented May 9, 2017

This can probably be closed; I believe Transpose has been rewritten since then for Sublime compatibility?

@gwk
Copy link
Author

gwk commented May 9, 2017

VSCode does not match TextEdit behavior in the following cases:

'\n^a'
'a^\n'
'ab^'

(where \n is newline and ^ is the insertion caret).

In all of these cases VSCode does nothing where TextEdit does a transpose operation.

@pbrit
Copy link

pbrit commented Jun 15, 2017

This can be closed. I can't reproduce this issue too. (version: 1.13.1)

@gwk
Copy link
Author

gwk commented Jun 15, 2017

I can still reproduce the cases I describe above on OSX; VSCode Version 1.14.0-insider 1cc8f3c.

I think that in order to close this issue somebody needs to explicitly decide that they want VSCode to ship with default behavior that does not match that of OSX and Cocoa.

@Zarel
Copy link
Contributor

Zarel commented Jun 15, 2017

I can reproduce, too. VS Code's transpose and transposeCharacters commands both do something different with each other and both different from the macOS/emacs standard.

@alexdima alexdima modified the milestones: Backlog, March 2018 Mar 26, 2018
@alexdima alexdima added verification-needed Verification of issue is requested and removed good first issue Issues identified as good for first-time contributors help wanted Issues identified as good community contribution opportunities labels Mar 27, 2018
@jrieken jrieken added the verified Verification succeeded label Mar 27, 2018
@vscodebot vscodebot bot locked and limited conversation to collaborators May 10, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
feature-request Request for new features or functionality macos Issues with VS Code on MAC/OS X verification-needed Verification of issue is requested verified Verification succeeded
Projects
None yet
9 participants