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

Do not record <CR> while in code completion, record chosen text instead. To be able to use the DOT command. [$50] #629

Open
Francescu opened this issue Sep 24, 2014 · 18 comments
Labels

Comments

@Francescu
Copy link

When using the native Xcode auto complete in insert mode, if I choose a suggestion and then press escape, the next time I use the DOT command XVim will write the beginning of the word I typed followed by a new line.

There is a $50 open bounty on this issue. Add to the bounty at Bountysource.

@Francescu Francescu changed the title Do not record <CR> while in autosuggestion, record chosen text instead. To be able to use the DOT command. Do not record <CR> while in code completion, record chosen text instead. To be able to use the DOT command. Sep 26, 2014
@Francescu
Copy link
Author

Could somebody give me some hints? Where should I start look at?

@pebble8888
Copy link
Member

DOT is implemented in method '- (XVimEvaluator*)DOT' in the file XVimNormalEvaluator.m .

If you will investigate it,

  1. put 'set debug' to your ~/.xvimrc file.
  2. In terminal type 'tail -f ~/.xvimlog'.
  3. put DEBUG_LOG() in DOT method.
  4. build XVim and reboot Xcode.
  5. Think why does DOT command behave like this.

@pebble8888
Copy link
Member

A keyStroke is put to the repeat register by [XVim appendOperaitonKeyStroke:].
Auto completed text by Xcode is not put to the repeat register.
It may be put by hooking DVTTextCompletionController.
Hooking Xcode class method is not easy task.

@JugglerShu
Copy link
Contributor

Well, I think the actual issue is not that the auto completed text is recorded into the register but is recorded into the register because when fix the auto completion you have to hit enter.
So anyway one way to fix this we need to add conditional block that handles when auto completion is on. It can be determined by accessing DVTTextCompletionController and DVTTextCompletionSession.

Sorry I do not have enough time to fix this soon...

@Francescu
Copy link
Author

Ok I think I have found the flow logic the fix the issue. Problem is I can't try to fix that because I can't run the app. (I am under Yosemite).

Edit: Removed crash log as problem is fixed

@JugglerShu
Copy link
Contributor

I have the same problem I can not debug Xcode6 by Xcode6 but I can debug Xcode6 by Xcode5.

@unphased
Copy link

+1 to this issue, I'm used to vim and YCM which handles this case quite gracefully.

@unphased
Copy link

unphased commented Dec 3, 2014

#628 lets us debug it!

@Francescu
Copy link
Author

I looked at it (a little). As a first quickfix what do you think if I'd prevent CR, Up and Down in XVimWindow-handleOneXVimString: while autoCompletion window is open?

@gfontenot
Copy link
Contributor

Are you talking about disabling those keys entirely during autocomplete? If so, then that's going to get the hugest of all possible 👎s from me. Breaking Xcode's functionality to "fix" XVim's functionality shouldn't even be a conversation.

@Francescu
Copy link
Author

No that would be stupid. I'm talking about prevent the recording of those keys in XVim to avoid to reuse them in DOT or q/@ as they actually do nothing in the editor.

Now, the focus is in the AutoCompletion window and those keys are used for browsing the list and validate the completion choice. So those keys do nothing in the editor and in XVim but they still are recorded for DOT commands.

@unphased
Copy link

hmm yeah it is half the equation, the other half is to extract what the menu choice expands to.

@transitive-bullshit
Copy link

+1

@minwhoo
Copy link

minwhoo commented Jul 1, 2015

Any update on this issue?

1 similar comment
@edhub
Copy link

edhub commented Jul 14, 2015

Any update on this issue?

@unphased
Copy link

A note for those looking to implement this. Even if there exists no API to "fetch" the text involved with the autocomplete choice that was made, the state of the editor buffer can offer the definitive answer as to what that value was. It might be possible to do a scan backward in the buffer to read out what the value that was "typed". I think it may be tricky. Because I think XCode is nice and allows fuzzy matching. That would make reconciling the keystrokes a bit tricky... Hopefully not too hard to do.

@jordwalke
Copy link

+1

hmuronaka added a commit to hmuronaka/XVim that referenced this issue Sep 27, 2015
hmuronaka added a commit to hmuronaka/XVim that referenced this issue Sep 28, 2015
@hmuronaka
Copy link
Contributor

I tried to fix it.

But it doesn't work correctly if completionText contains placeholder.

For example

// You type the code using completion.
[NSString stringWithFormat:@"Test"]

// Xcode will complete like this if completionText contains placeholder.
[NSString  stringWithFormat:(nonnull NSString *), ... @"Test"];

hmuronaka added a commit to hmuronaka/XVim that referenced this issue Sep 29, 2015
hmuronaka added a commit to hmuronaka/XVim that referenced this issue Oct 26, 2015
@JugglerShu JugglerShu changed the title Do not record <CR> while in code completion, record chosen text instead. To be able to use the DOT command. Do not record <CR> while in code completion, record chosen text instead. To be able to use the DOT command. [$50] Nov 12, 2015
hmuronaka added a commit to hmuronaka/XVim that referenced this issue Dec 10, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

10 participants