Skip to content

Commit 0b3210a

Browse files
committed
Adds helper function to onHover for comment-doc formatting
1 parent 8905da4 commit 0b3210a

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

server/src/server.ts

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,11 @@ export default class BashServer {
180180
return { contents: getMarkdownContent(shellDocumentation) }
181181
}
182182
} else {
183+
const getCommentsAbove = (uri: string, line: number): string => {
184+
const comment = this.analyzer.commentsAbove(uri, line)
185+
return comment ? `\n\n${comment}` : ''
186+
}
187+
183188
const symbolDocumentation = deduplicateSymbols({
184189
symbols: this.analyzer.findSymbolsMatchingWord({
185190
exactMatch: true,
@@ -194,16 +199,15 @@ export default class BashServer {
194199
? `${symbolKindToDescription(symbol.kind)} defined in ${path.relative(
195200
currentUri,
196201
symbol.location.uri,
197-
)}\n\n${this.analyzer.commentsAbove(
202+
)}${getCommentsAbove(
198203
symbol.location.uri,
199204
symbol.location.range.start.line,
200205
)}`
201206
: `${symbolKindToDescription(symbol.kind)} defined on line ${symbol.location
202-
.range.start.line + 1}
203-
\n\n${this.analyzer.commentsAbove(
204-
params.textDocument.uri,
205-
symbol.location.range.start.line,
206-
)}`,
207+
.range.start.line + 1}${getCommentsAbove(
208+
params.textDocument.uri,
209+
symbol.location.range.start.line,
210+
)}`,
207211
)
208212

209213
if (symbolDocumentation.length === 1) {

0 commit comments

Comments
 (0)