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

Sublime command palette inserts numbers one space before the cursor #16

Closed
amclain opened this issue May 2, 2014 · 14 comments
Closed
Assignees

Comments

@amclain
Copy link

amclain commented May 2, 2014

There seems to be a bug when using Sublime's command palette to insert numbers. When the command is executed, the numbers are inserted one character behind the cursor. This does not seem to be the case if the Text-Pastry command line is used directly.

Given the following segment of code as an example, the goal is to insert a number before the semicolon: constant_1 = 101;

constant_1 = ;
constant_2 = ;
constant_3 = ;
constant_4 = ;

So the first step is to position multiple cursors (illustrated wtih |) just before the semicolon, just as you would if you were to start typing more text. Although this may appear obvious, I state it because it is an important issue regarding the bug.

constant_1 = |;
constant_2 = |;
constant_3 = |;
constant_4 = |;

Open Sublime's command palette via ctrl + shift + p, select Text Pastry: Command Line, and enter \i101. The inserted numbers end up behind the cursor location.

constant_1 =101 ;
constant_2 =102 ;
constant_3 =103 ;
constant_4 =104 ;

Running the same command by opening the Text-Pastry command line directly with the respective hotkey (not through Sublime's command palette) works as expected.

constant_1 = 101;
constant_2 = 102;
constant_3 = 103;
constant_4 = 104;
@bseymore
Copy link

bseymore commented May 2, 2014

I just tried this on my system and it works as expected — with the keyboard shortcut, the numbers are inserted before the semicolon, with no extraneous white space, like in your fourth example.

This is with SublimeText 3 (Build 3061) and Text Pastry 1.3.5 on an OS X 10.9.2 machine.

@amclain
Copy link
Author

amclain commented May 2, 2014

Looks like this may be an interaction with the Vintage plugin. I was able to catch that opening the Text-Pastry command line via the Sublime command palette forces Vintage out of insert mode (| cursor) and into command mode (_ cursor).

So when the editor is in insert mode, this is how the cursors appear:

command_1 = |;
command_2 = |;
command_3 = |;
command_4 = |;

Debug output:

(12, 12)
(27, 27)
(42, 42)
(57, 57)

Opening the Text-Pastry command line from the Sublime command palette then bumps the editor into command mode, changing the cursor to:

command_1 =_;
command_2 =_;
command_3 =_;
command_4 =_;
(11, 11)
(26, 26)
(41, 41)
(56, 56)

I should note that commands like Text Pastry: From 1 To X do keep the editor in insert mode and behave correctly, but it's starting to look like this may actually be an issue with Vintage.

I'm on ST3 build 3059 on various Win 7 and Linux machines, same configuration and same behavior for all.

@duydao
Copy link
Owner

duydao commented May 3, 2014

I'm unfamiliar with the vintage plugin, but I'll take a look. Does this also happen with an other plugin?

@duydao
Copy link
Owner

duydao commented May 3, 2014

@ bseymore thanks for the quick check!

@amclain
Copy link
Author

amclain commented May 4, 2014

Whoops, I got my plugin names mixed up. Vintage and Vintageous are Vim emulator plugins. I meant to say Vintageous previously.

Vintage ships with Sublime Text 3 but is an ignored package in the default config. It's enabled by removing it from the ignored packages list. I enabled this plugin and it does seem to work correctly with Text-Pastry.

Vintageous is a rewrite of Vintage; they should not be enabled at the same time. With this plugin enabled, the undesired behavior returns.

Based on this, it looks like the bug may be due to Vintageous changing the cursor mode when the Sublime command palette is opened. It just so happens that I noticed the bug because I do frequent text insertion with Text-Pastry this way, making it appear like it was the plugin at fault.

@duydao
Copy link
Owner

duydao commented May 6, 2014

OK, thanks for clarifying!

@duydao
Copy link
Owner

duydao commented Jun 7, 2014

I'll take another look at this

@duydao duydao reopened this Jun 7, 2014
@duydao
Copy link
Owner

duydao commented Jun 8, 2014

@amclain I tried to reproduce this bug, but it worked as expected. can you confirm that this still is a problem?

Steps

  • paste text
  • press i to enter insert mode
  • place cursor like described:
constant_1 = |;
constant_2 = |;
constant_3 = |;
constant_4 = |;
  • open command palette with shortcut OR open TP Command line with shortcut
  • enter 1 10 0

Result

  • the expected numbers were inserted
  • the numbers were selected
  • vintageous was still in edit mode

Note
I've tried this on a mac, will try on a windows plattform shortly

@duydao
Copy link
Owner

duydao commented Jun 12, 2014

@amclain I was able to reproduce this problem, checking for a workaround

@duydao duydao self-assigned this Jun 12, 2014
@duydao
Copy link
Owner

duydao commented Jun 13, 2014

relevant lines in vintageous are:

on_deactivate, 80-82

on_activate, 56-58

@duydao
Copy link
Owner

duydao commented Jun 13, 2014

Basically, vintageous will reset its mode to "normal mode" after losing focus. I've asked the creator of vintageous to add an option to enable/disable this behaviour. Can't do anything else, sorry.

@duydao duydao closed this as completed Jun 13, 2014
@amclain
Copy link
Author

amclain commented Jun 14, 2014

Thanks for tracking down the lines of code in Vintageous that were causing the problem! I understand this is their problem and not yours, but what you were able to find looks like a big help.

@Kcko
Copy link

Kcko commented Jan 20, 2015

Hi Bro,

sequence i or \i (not work -- generate only "i").
When i change this to \i(1) or i1 its works....

it worked in the past, can u tell me why? :]]

Scr: http://files.rjwebdesign.cz/i/20150120-151153---1487x1028---t---pn.png

S pozdravem

Roman Janko
webdesigner & developer

gsm: [+420] 777 856 657
email: admin@rjwebdesign.cz mailto:admin@rjwebdesign.cz
icq: 176-031-471
www: rjwebdesign.cz http://rjwebdesign.cz
linkedin: linkedin.com/in/romanjanko
http://www.linkedin.com/in/romanjanko
twitter: twitter.com/RomanJanko https://twitter.com/RomanJanko

Rjwebdesign logo

Dne 7.6.2014 v 18:01 Duy Dao napsal(a):

I'll take another look at this


Reply to this email directly or view it on GitHub
#16 (comment).

@duydao
Copy link
Owner

duydao commented Jan 20, 2015

Thanks for reporting this issue, I've created #27 for this bug

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

No branches or pull requests

4 participants