def SetCurrentFrame( self, frame ): """Returns True if the code window was updated with the frame, False otherwise. False means either the frame is junk, we couldn't find the file (or don't have the data) or the code window no longer exits.""" if self._signs[ 'vimspectorPC' ]: vim.command( 'sign unplace {} group=VimspectorCode'.format( self._signs[ 'vimspectorPC' ] ) ) self._signs[ 'vimspectorPC' ] = None if not frame or not frame.get( 'source' ): return False if 'path' not in frame[ 'source' ]: return False self._signs[ 'vimspectorPC' ] = self._next_sign_id self._next_sign_id += 1 try: vim.command( 'sign place {0} group=VimspectorCode priority=20 ' 'line={1} name=vimspectorPC ' 'file={2}'.format( self._signs[ 'vimspectorPC' ], frame[ 'line' ], frame[ 'source' ][ 'path' ] ) ) except vim.error as e: # Ignore 'invalid buffer name' if 'E158' not in str( e ): raise if not self._window.valid: return False utils.JumpToWindow( self._window ) try: utils.OpenFileInCurrentWindow( frame[ 'source' ][ 'path' ] ) except vim.error: self._logger.exception( 'Unexpected vim error opening file {}'.format( frame[ 'source' ][ 'path' ] ) ) return False # SIC: column is 0-based, line is 1-based in vim. Why? Nobody knows. # Note: max() with 0 because some debug adapters (go) return 0 for the # column. try: self._window.cursor = ( frame[ 'line' ], max( frame[ 'column' ] - 1, 0 ) ) except vim.error: self._logger.exception( "Unable to jump to %s:%s in %s, maybe the file " "doesn't exist", frame[ 'line' ], frame[ 'column' ], frame[ 'source' ][ 'path' ] ) return False self.current_syntax = utils.ToUnicode( vim.current.buffer.options[ 'syntax' ] ) return True
def SetCurrentFrame( self, frame ): if self._signs[ 'vimspectorPC' ]: vim.command( 'sign unplace {} group=VimspectorCode'.format( self._signs[ 'vimspectorPC' ] ) ) self._signs[ 'vimspectorPC' ] = None if not frame or not frame.get( 'source' ): return False if 'path' not in frame[ 'source' ]: return False utils.JumpToWindow( self._window ) try: utils.OpenFileInCurrentWindow( frame[ 'source' ][ 'path' ] ) except vim.error: self._logger.exception( 'Unexpected vim error opening file {}'.format( frame[ 'source' ][ 'path' ] ) ) return False # SIC: column is 0-based, line is 1-based in vim. Why? Nobody knows. # Note: max() with 0 because some debug adapters (go) return 0 for the # column. try: self._window.cursor = ( frame[ 'line' ], max( frame[ 'column' ] - 1, 0 ) ) except vim.error: self._logger.exception( "Unable to jump to %s:%s in %s, maybe the file " "doesn't exist", frame[ 'line' ], frame[ 'column' ], frame[ 'source' ][ 'path' ] ) return False self._signs[ 'vimspectorPC' ] = self._next_sign_id self._next_sign_id += 1 vim.command( 'sign place {0} group=VimspectorCode priority=20 ' 'line={1} name=vimspectorPC ' 'file={2}'.format( self._signs[ 'vimspectorPC' ], frame[ 'line' ], frame[ 'source' ][ 'path' ] ) ) self.current_syntax = utils.ToUnicode( vim.current.buffer.options[ 'syntax' ] ) return True
def SetCurrentFrame(self, frame): """Returns True if the code window was updated with the frame, False otherwise. False means either the frame is junk, we couldn't find the file (or don't have the data) or the code window no longer exits.""" if not frame or not frame.get('source'): self._UndisplayPC() return False if 'path' not in frame['source']: self._UndisplayPC() return False self._current_frame = frame if not self._window.valid: return False utils.JumpToWindow(self._window) try: utils.OpenFileInCurrentWindow(frame['source']['path']) vim.command('doautocmd <nomodeline> User VimspectorJumpedToFrame') except vim.error: self._logger.exception( 'Unexpected vim error opening file {}'.format( frame['source']['path'])) return False # SIC: column is 0-based, line is 1-based in vim. Why? Nobody knows. # Note: max() with 0 because some debug adapters (go) return 0 for the # column. try: utils.SetCursorPosInWindow(self._window, frame['line'], frame['column']) except vim.error: self._logger.exception( "Unable to jump to %s:%s in %s, maybe the file " "doesn't exist", frame['line'], frame['column'], frame['source']['path']) return False self.current_syntax = utils.ToUnicode( vim.current.buffer.options['syntax']) self._DisplayPC() return True