Skip to content

Commit

Permalink
Merge pull request #164 from pappasam/debug-to-stderr
Browse files Browse the repository at this point in the history
Debug to stderr
  • Loading branch information
pappasam committed Sep 27, 2021
2 parents 578cf4d + 80afc84 commit 5edbb2a
Show file tree
Hide file tree
Showing 4 changed files with 160 additions and 125 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## 0.34.5

### Fixed

- InitializationOption `jediSettings.debug` now writes to stderr, not stdout. stdout broke the language server.

## 0.34.4

### Added
Expand Down
14 changes: 13 additions & 1 deletion jedi_language_server/jedi_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
Translates pygls types back and forth with Jedi
"""

import sys
from inspect import Parameter
from typing import Dict, List, Optional

Expand Down Expand Up @@ -33,6 +34,17 @@
from .type_map import get_lsp_completion_type, get_lsp_symbol_type


def _jedi_debug_function(
color: str, # pylint: disable=unused-argument
str_out: str,
) -> None:
"""Jedi debugging function that prints to stderr.
Simple for now, just want it to work.
"""
print(str_out, file=sys.stderr)


def set_jedi_settings( # pylint: disable=invalid-name
initialization_options: InitializationOptions,
) -> None:
Expand All @@ -48,7 +60,7 @@ def set_jedi_settings( # pylint: disable=invalid-name
initialization_options.jedi_settings.case_insensitive_completion
)
if initialization_options.jedi_settings.debug:
jedi.set_debug_function()
jedi.set_debug_function(func_cb=_jedi_debug_function)


def script(project: Optional[Project], document: Document) -> Script:
Expand Down
Loading

0 comments on commit 5edbb2a

Please sign in to comment.