Skip to content

Commit

Permalink
Auto merge of #1545 - micbou:echom-redraw, r=Valloric
Browse files Browse the repository at this point in the history
Redraw the screen before displaying a message

There has been several complaints about the message "ValueError: File is less than 5 lines long; not compiling". See issues #814, #1364, #1544. In fact, I believe the issue is not the message itself but the infamous "Press ENTER or type command to continue" prompt when editing a new C-family file.

For example, if I create the file `foo.c`, Vim will display the line `"foo.c" [New file]` and then YouCompleteMe will display `ValueError: File is less than 5 lines long; not compiling`. Since there are now two lines, the hit-enter message is prompted. By redrawing the screen just before displaying the message from YouCompleteMe, only one line appears and we avoid this behavior.

Tested on Linux and Windows.

CLA signed.
  • Loading branch information
homu committed Jun 22, 2015
2 parents a24cc3c + 69eee20 commit 66dcc95
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions python/ycm/vimsupport.py
Expand Up @@ -358,11 +358,13 @@ def NumLinesInBuffer( buffer_object ):
return len( buffer_object )


# Calling this function from the non-GUI thread will sometimes crash Vim. At the
# time of writing, YCM only uses the GUI thread inside Vim (this used to not be
# the case).
# Calling this function from the non-GUI thread will sometimes crash Vim. At
# the time of writing, YCM only uses the GUI thread inside Vim (this used to
# not be the case).
# We redraw the screen before displaying the message to avoid the "Press ENTER
# or type command to continue" prompt when editing a new C-family file.
def PostVimMessage( message ):
vim.command( "echohl WarningMsg | echom '{0}' | echohl None"
vim.command( "redraw | echohl WarningMsg | echom '{0}' | echohl None"
.format( EscapeForVim( str( message ) ) ) )


Expand Down

0 comments on commit 66dcc95

Please sign in to comment.