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

NeoVintageous messes with Quickpanel input{} completion #1329

Open
DrBones opened this issue May 28, 2018 · 20 comments
Open

NeoVintageous messes with Quickpanel input{} completion #1329

DrBones opened this issue May 28, 2018 · 20 comments
Labels

Comments

@DrBones
Copy link

DrBones commented May 28, 2018

When typing \input{ and then choosing something from the quickpanel that pops up I get a correct completion but at one character earlier when also using NeoVintageous, e.g \inpu{CompletedFilenameHere}t
This also happens with all other command that use the quickpanel, like \cite{ or \ref{

This might be more of a bug in Neovintageous but it only occurs in combination with LatexTools. I believe this is rather recent as I use the autocomplete extensively.

Also, when no other extensions or custom config is used.

System:
Windows 10
Sublime Build 3176
LatexTools 3.15.1
NeoVintageous 1.6.2

@r-stein
Copy link
Member

r-stein commented May 28, 2018

That's weird can you open the ST console and log commands (sublime.log_commands(True)) and inputs (sublime.log_input(True)) when this happens?

@DrBones
Copy link
Author

DrBones commented May 28, 2018

Hi, that was fast. Sure!

The console throws a lot of ghostscript and external_command.py errors.

Here is the full output

chr evt: i (0x69)
chr evt: n (0x6e)
chr evt: p (0x70)
chr evt: u (0x75)
chr evt: t (0x74)
Error finding Ghostscript version for None
Traceback (most recent call last):
  File "C:\Users\username\Downloads\Sublime Text Build 3176 x64\Data\Packages\LaTeXTools\st_preview\preview_utils.py", line 99, in _update_gs_version
    raw_version = check_output([_GS_COMMAND, '-version'])
  File "C:\Users\username\Downloads\Sublime Text Build 3176 x64\Data\Packages\LaTeXTools\latextools_utils\external_command.py", line 348, in check_output
    show_window=show_window
  File "C:\Users\username\Downloads\Sublime Text Build 3176 x64\Data\Packages\LaTeXTools\latextools_utils\external_command.py", line 268, in execute_command
    show_window=show_window
  File "C:\Users\username\Downloads\Sublime Text Build 3176 x64\Data\Packages\LaTeXTools\latextools_utils\external_command.py", line 181, in external_command
    if not os.path.isabs(command[0]):
  File "./python3.3/ntpath.py", line 102, in isabs
  File "./python3.3/ntpath.py", line 162, in splitdrive
TypeError: object of type 'NoneType' has no len()
key evt: control+alt+7
chr evt: { (0x7b)
command: latex_fill_all {"completion_type": "input", "insert_char": "{"}
Error finding Ghostscript version for None
Traceback (most recent call last):
  File "C:\Users\\Downloads\Sublime Text Build 3176 x64\Data\Packages\LaTeXTools\st_preview\preview_utils.py", line 99, in _update_gs_version
    raw_version = check_output([_GS_COMMAND, '-version'])
  File "C:\Users\username\Downloads\Sublime Text Build 3176 x64\Data\Packages\LaTeXTools\latextools_utils\external_command.py", line 348, in check_output
    show_window=show_window
  File "C:\Users\username\Downloads\Sublime Text Build 3176 x64\Data\Packages\LaTeXTools\latextools_utils\external_command.py", line 268, in execute_command
    show_window=show_window
  File "C:\Users\username\Downloads\Sublime Text Build 3176 x64\Data\Packages\LaTeXTools\latextools_utils\external_command.py", line 181, in external_command
    if not os.path.isabs(command[0]):
  File "./python3.3/ntpath.py", line 102, in isabs
  File "./python3.3/ntpath.py", line 162, in splitdrive
TypeError: object of type 'NoneType' has no len()
Error finding Ghostscript version for None
Traceback (most recent call last):
  File "C:\Users\username\Downloads\Sublime Text Build 3176 x64\Data\Packages\LaTeXTools\st_preview\preview_utils.py", line 99, in _update_gs_version
    raw_version = check_output([_GS_COMMAND, '-version'])
  File "C:\Users\username\Downloads\Sublime Text Build 3176 x64\Data\Packages\LaTeXTools\latextools_utils\external_command.py", line 348, in check_output
    show_window=show_window
  File "C:\Users\username\Downloads\Sublime Text Build 3176 x64\Data\Packages\LaTeXTools\latextools_utils\external_command.py", line 268, in execute_command
    show_window=show_window
  File "C:\Users\username\Downloads\Sublime Text Build 3176 x64\Data\Packages\LaTeXTools\latextools_utils\external_command.py", line 181, in external_command
    if not os.path.isabs(command[0]):
  File "./python3.3/ntpath.py", line 102, in isabs
  File "./python3.3/ntpath.py", line 162, in splitdrive
TypeError: object of type 'NoneType' has no len()

The control+alt+7 comes from my german keyboard layout.

@r-stein
Copy link
Member

r-stein commented May 28, 2018

Okay that error handling is something we must improve. The other output looks as expected. We will need more investigation in this.

@r-stein r-stein added the bug label May 28, 2018
@gerardroche
Copy link

gerardroche commented May 31, 2018

This is a NeoVintageous issue, explained here: NeoVintageous/NeoVintageous#357. That said, LatextTools could apply a workaround, by checking if command_mode is true and the cursor is on the last character of the line then +1 to the col.

Check if command_mode is true:

is_command_mode = view.settings().get('command_mode')

@r-stein
Copy link
Member

r-stein commented May 31, 2018

Sorry can you please elaborate. Shall we insert the test a character later if it is at the end of a line and in command mode (which would be the first char in the next line)?

@gerardroche
Copy link

gerardroche commented May 31, 2018

No, it won't be the character in the next line, it will be the point before the eol character \n.

When in command mode the cursor is an inverted caret:

screenshot from 2018-05-31 15-23-11

The insert point above is before the letter b.

When the cursor is at the end of a line, the insert point is before the letter c:

screenshot from 2018-05-31 15-16-42

In vim if you wanted to enter INSERT mode after the cursor character press a:

screenshot from 2018-05-31 15-32-30

The cursor is now before an invisible newline.

So... if in command mode and the cursor is on the last character of the line, then the insertion point needs to be + 1, because if the user is in INSERT mode at the eol:

screenshot from 2018-05-31 15-32-30

And latexttools invokes an overylay, NeoVintageous will reset to command mode:

screenshot from 2018-05-31 15-16-42

When the user now selects from the overlay, and latextools does an insert, it will insert before the letter c.

This is only an issue at the eol, because if the user is INSERT mode anywhere else:

screenshot from 2018-05-31 15-47-17

And neovintageous resets to command mode it will be at the correct position:

screenshot from 2018-05-31 15-23-11

This is all expected Vim behaviour, except for NeoVintageous resetting to command mode. If you don't use Vim this probably looks pretty insane.

I don't know if that makes sense, it's kinda complicated to explain if you're not a Vim user, because it looks impossible, but it actually makes complete sense in Vim.

More info: NeoVintageous/NeoVintageous@239b3bf

--- edit ---

Technically, the last one should actually reset to command mode before the letter a rather than the letter b. To fix that will require significant changes in NeoVintageous, because lots of commands depend on the current behaviour.

@SolidTux
Copy link

SolidTux commented Jul 31, 2018

I tried to make a workaround for this. Is there anything missing?

@DrBones
Copy link
Author

DrBones commented Jul 31, 2018

I tried your workaround and it seems to be fixing the issue. Thank you!

P.S.: When should this be closed, when the new version with this fix comes out or when the pull request is merged?

@SolidTux
Copy link

SolidTux commented Jul 31, 2018

I just noticed, that this doesn't completely solve the issue. It fails, when there is one character after the cursor in input mode. I don't think this can be solved from here as the resulting position in the command mode is exactly the same.

But I think this is still a bit better than the previous behavior as I think the case where you are at the end of the line is much more common that one character before that.

Edit: fix bad grammar

@DrBones
Copy link
Author

DrBones commented Jul 31, 2018

You are right. Odd.

Especially since that is something that worked correctly before, only when the cursor was on the last position did the insert fail.

I am not familiar with how exactly command mode is entered but theoretically if the cursor is in front of a character it should move over the one left to it when entering command mode. So their positions should be different, I think.

When testing, the selection showed the correct position, a '\n' when on the last character and the last charcter when in front of that.
caret_positon

However, when printing from the latex_fill_all.py is always showed a newline.
Also, is it supposed to run twice? Maybe the insertion of the braces messes stuff up...

Sorry to not be of more help, I do concur though, I more often insert a citation at the end.

@r-stein
Copy link
Member

r-stein commented Jul 31, 2018

I am wondering if the command mode setting is unique to neovintageous or also used in other vim emulators?

@DrBones
Copy link
Author

DrBones commented Jul 31, 2018

I believe the command mode is actually something Sublime Text supplies for just this use case.
Command Mode Docs

If that is actually used by the vim emulators, I don't know but I assume it is.

@r-stein
Copy link
Member

r-stein commented Jul 31, 2018

Can you please try whether this fix also works for the normal command mode or creates a problem there. If so we need to check that it is the neovintageous command mode.

@pSpitzner
Copy link

Probably related to this issue, I noticed that with the default setting "vintageous_reset_mode_when_switching_tabs": true, insert mode is deactivated after selecting a suggestion from the quickpanel.

I had a look at SolidTux's LaTeXTools workaround and I suppose one could get the current vim mode in a similar fashion, before opening the quickpanel and then return to the initial mode after pating.

@dhelonious
Copy link

I solved this problem for me with some ugly workaround based on SolidTux's suggestion. This should prevent issues in all reasonable situations.

@paschalis-mpeis
Copy link

I still have this issue on MacOSX. It's very annoying.I had issues with every autocompletion command(input, cite, ref, gls for acronyms, etc..)

@dhelonious solution based on @SolidTux comments is a few commits back from latest version of LatexTools. But I put it again on the latest commit (45376f1) and it work.
I've been testing this for a few days, and I can tell that the issue is completely fixed.

@r-stein I've made a pull request #1457 . Can you please consider merging that into the repository?

@pluskid
Copy link

pluskid commented Feb 6, 2020

I'm having the same issue. How can I install the workaround?

@gerardroche
Copy link

gerardroche commented Feb 7, 2020

A quick workaround may be for you to disable vintageous_reset_mode_when_switching_tabs:

Open your settings Menu > Preferences > Settings and set:

"vintageous_reset_mode_when_switching_tabs": false,

That will prevent nv from resetting to normal mode when the view reactivates after the overlay is closed.

If you prefer insert mode by default you can do that instead:

    // Default mode to use when activating or switching views.
    // Valid values are: "insert"
    //
    // mode   | description
    // ------ | -----------
    // insert | Enter insert mode when opening or switching views or when
    //          the window receives focus and is not in visual mode i.e. visual
    //          mode selections are retained when the window loses focus.
    //
    // {not in Vim}
    "vintageous_default_mode": "insert",

There is an EOF bug which I don't think relates to NeoVintageous or Vintage:

For example in the following where the cursor is | and is at the EOF meaning there is no newline at the eof:

\input|

Then pressing { opens the overlay and when you press enter you get:

\input
{test|}

I don't think that bug relates to Neovintageous or Vintage but may be confusing the issue because it looks like fixes for the Vim mode issues are trying to also fix the above issue too.

@gerardroche
Copy link

gerardroche commented Feb 7, 2020

To fix the insertion point when the cursor is at the eol:

                insertion_pt = sel.end()
                if view.settings().get('command_mode') and view.substr(insertion_pt + 1) == "\n":
                    insertion_pt += 1

                view.insert(edit, insertion_pt, value)

In terms of fixing the right cursor position after the insertions are done is more complicated because complete_auto_match() adjusts the cursor position after the insertions have been done. I don't know how to resolve that.

There is still also the bug when the cursor is at the eof which impacts LatexTools irregardless of vim-modes.

@pluskid
Copy link

pluskid commented Feb 8, 2020

@gerardroche Thanks a lot! This workaround seem to be good enough for me for now!

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

8 participants