Skip to content

Conversation

jordanbreen28
Copy link
Contributor

@jordanbreen28 jordanbreen28 commented Apr 15, 2024

Summary

Prior to this PR, when selecting a param/prop from the dropdown completion list in puppet-vscode, the hash rocket would not be formatted inline with the rest of the document.

This PR implements a middleware to the language client, and adds a vscode API item command which allows us to execute a vscode command after the selection of the param/prop from the dropdown list. So when an param/prop is selected, we send a callback event to the language server to format the document.

This is only possible on the vscode side thanks to the vscode API, unfortunately there is no suitable events to implement this into the langauge server.
Also not possible as:

  1. The LSP does not provide adequate data to the language-server to retrieve the file content and then format on the language server side
  2. Even still, there is no way to guarantee correct formatting when we can only return the completion item, as if we returned the entire formatted document that would be inserted where the cursor is, leading to duplicate and inconsistent formatting with props/params.

Related Issues (if any)

Fixes #884

Checklist

  • 🟢 Spec tests.
  • 🟢 Acceptance tests.
  • Manually verified.

@codecov
Copy link

codecov bot commented Apr 15, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 77.77%. Comparing base (2681e30) to head (d505e68).

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #882   +/-   ##
=======================================
  Coverage   77.77%   77.77%           
=======================================
  Files           1        1           
  Lines           9        9           
=======================================
  Hits            7        7           
  Misses          2        2           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@jordanbreen28 jordanbreen28 force-pushed the cat-1669-fix_hashrocket_allignment branch 5 times, most recently from a25d82d to 4c5d8e9 Compare April 15, 2024 15:05
@jordanbreen28 jordanbreen28 marked this pull request as ready for review April 15, 2024 15:46
@jordanbreen28 jordanbreen28 requested a review from a team as a code owner April 15, 2024 15:46
@jordanbreen28 jordanbreen28 force-pushed the cat-1669-fix_hashrocket_allignment branch 4 times, most recently from bdf412d to e29e587 Compare April 16, 2024 12:28
@jordanbreen28 jordanbreen28 marked this pull request as draft April 16, 2024 12:53
@jordanbreen28 jordanbreen28 force-pushed the cat-1669-fix_hashrocket_allignment branch 3 times, most recently from 12fca26 to 3e73c69 Compare April 17, 2024 12:04
Prior to this commit, when selecting a param/prop from the dropdown
completion list in puppet-vscode, the hash rocket would not be formatted
inline with the rest of the document.

This commit implements a middleware to the language client, and adds a
vscode API item command which allows us to execute a vscode command
after the selection of the param/prop from the dropdown list. So when an
param/prop is selected, we send a callback event to the language server
to format the document.

This is only possible on the vscode side thanks to the vscode API,
unfortunately there is no suitable events to implement this into the
langauge server.
@jordanbreen28 jordanbreen28 force-pushed the cat-1669-fix_hashrocket_allignment branch 5 times, most recently from 4379f4f to d958291 Compare April 17, 2024 13:45
@jordanbreen28 jordanbreen28 force-pushed the cat-1669-fix_hashrocket_allignment branch from d958291 to d505e68 Compare April 17, 2024 13:53
@jordanbreen28 jordanbreen28 marked this pull request as ready for review April 17, 2024 13:55
@david22swan david22swan merged commit 00ade72 into main Apr 17, 2024
@david22swan david22swan deleted the cat-1669-fix_hashrocket_allignment branch April 17, 2024 14:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Hashrockets don't align after accepting autocomplete suggestion

2 participants