Repository: palantir/python-language-server

Issue:
TCP mode is not working since v0.15.0
When I attempt to start the language server in TCP mode using the command

``` pyls --tcp --host 127.0.0.1 --port 7003 ```

it fails to start the language server with the error ```Handler class must be an instance of PythonLanguageServer```

Discussion:

Patch:
diff --git a/pyls/_utils.py b/pyls/_utils.py
index fb353c3..56a8630 100644
--- a/pyls/_utils.py
+++ b/pyls/_utils.py
@@ -104,5 +104,5 @@ def format_docstring(contents):
 def clip_column(column, lines, line_number):
     # Normalise the position as per the LSP that accepts character positions > line length
     # https://github.com/Microsoft/language-server-protocol/blob/master/protocol.md#position
-    max_column = len(lines[line_number]) - 1 if len(lines) > line_number else 0
+    max_column = len(lines[line_number].rstrip('\r\n')) if len(lines) > line_number else 0
     return min(column, max_column)
diff --git a/pyls/python_ls.py b/pyls/python_ls.py
index 61de356..e1c9297 100644
--- a/pyls/python_ls.py
+++ b/pyls/python_ls.py
@@ -32,7 +32,7 @@ class _StreamHandlerWrapper(socketserver.StreamRequestHandler, object):
 
 
 def start_tcp_lang_server(bind_addr, port, handler_class):
-    if not isinstance(handler_class, PythonLanguageServer):
+    if not issubclass(handler_class, PythonLanguageServer):
         raise ValueError('Handler class must be an instance of PythonLanguageServer')
 
     # Construct a custom wrapper class around the user's handler_class


Test patch:
diff --git a/test/test_utils.py b/test/test_utils.py
index 6675374..9d00686 100644
--- a/test/test_utils.py
+++ b/test/test_utils.py
@@ -52,6 +52,12 @@ def test_merge_dicts():
 
 
 def test_clip_column():
-    assert _utils.clip_column(5, ['123'], 0) == 2
-    assert _utils.clip_column(2, ['\n', '123'], 1) == 2
     assert _utils.clip_column(0, [], 0) == 0
+    assert _utils.clip_column(2, ['123'], 0) == 2
+    assert _utils.clip_column(3, ['123'], 0) == 3
+    assert _utils.clip_column(5, ['123'], 0) == 3
+    assert _utils.clip_column(0, ['\n', '123'], 0) == 0
+    assert _utils.clip_column(1, ['\n', '123'], 0) == 0
+    assert _utils.clip_column(2, ['123\n', '123'], 0) == 2
+    assert _utils.clip_column(3, ['123\n', '123'], 0) == 3
+    assert _utils.clip_column(4, ['123\n', '123'], 1) == 3