Skip to content

Commit

Permalink
🐛 Fix document link
Browse files Browse the repository at this point in the history
  • Loading branch information
Freed-Wu committed Dec 21, 2023
1 parent 8096642 commit 60b43ff
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ A screencast authored by @rbmarliere:

[![asciicast](https://camo.githubusercontent.com/aa2be3ad710e855b3e6b7cd55f5261ac7582f1e69c8947f4619ba4c96f8cc506/68747470733a2f2f61736369696e656d612e6f72672f612f3631303634352e737667)](https://asciinema.org/a/610645)

![document link](https://github.com/neomutt/mutt-language-server/assets/32936898/7db39120-401e-4be7-82c4-827609ab7f26)

See
[![readthedocs](https://shields.io/readthedocs/mutt-language-server)](https://mutt-language-server.readthedocs.io)
to know more.
Expand Down
10 changes: 5 additions & 5 deletions src/mutt_language_server/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
from platformdirs import user_cache_dir
from pygls.server import LanguageServer

PAT = re.compile(r"(?<=\bsource\b\s)\w+")
PAT = re.compile(r"(?<=\bsource\b\s)\S+")


def get_document(
Expand Down Expand Up @@ -106,13 +106,13 @@ def document_link(params: DocumentLinkParams) -> list[DocumentLink]:
links = []
for i, line in enumerate(document.source.splitlines()):
for m in PAT.finditer(line):
url = os.path.join(
os.path.dirname(params.text_document.uri),
m.groups()[0],
)
_range = Range(
Position(i, m.start()), Position(i, m.end())
)
url = os.path.join(
os.path.dirname(params.text_document.uri),
os.path.expanduser(line[m.start() : m.end()]),
)
links += [DocumentLink(_range, url)]
return links

Expand Down

0 comments on commit 60b43ff

Please sign in to comment.