microsoft / microsoft/TypeScript-Sublime-Plugin

Diagnostics for an empty region does not show up

Open
#637 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
1.7k
Forks
236
Avg merge
21d 13h
Merged PRs (30d)
1

Description

I'm using tslint-language-service, and it works fine except for rules like semicolon or trailing-comma. The diagnostics produced by these rules correctly end up in Sublime, but they don't get rendered because they appear inside an empty region at the end of the line and Sublime refuses to render them:

image

I've added a quick workaround, like this:

diff --git typescript/listeners/idle.py typescript/listeners/idle.py
index f48df56..30e6a8f 100644
--- typescript/listeners/idle.py
+++ typescript/listeners/idle.py
@@ -146,6 +146,9 @@ class IdleListener:
                     # character instead so user can still see the highlight.
                     if start == view.size() and start == end:
                         region = last_visible_character_region(view)
+                    elif start == view.line(start).end() and start == end:
+                        end = view.text_point(start_line + 1, 0)
+                        region = sublime.Region(start, end)
                     else:
                         region = sublime.Region(start, end)

which seems to at least put a small red squiggle at the end of the line:

image

but hovering over it to get the message doesn't work. It also seems that the issue is more general, in that any region that only contains whitespace does not show up, e.g. when I add some trailing spaces:

image

so while this is a conservative change that solves this specific issue with semicolon and trailing-comma, I'm not sure this is the right solution in the general case. SublimeLinter adds a gutter mark for empty regions, so maybe that's a viable solution?

For reference, this behaves properly in VSCode:

image
image

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in typescript/listeners/idle.py around IdleListener's region construction and reproduce the issue with semicolon or trailing-comma diagnostics at line ends and whitespace-only regions. Compare the existing workaround with SublimeLinter's gutter behavior; done means empty or whitespace-only diagnostics are visible and their messages can be opened in Sublime.

Written by the indexing model from the issue text.

Assessment

Tech stack
python, typescript
Domain
developer-experience, tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.