Skip to content

Commit

Permalink
Merge pull request #9 from mistweaverco/feat/vscode-named-requests-su…
Browse files Browse the repository at this point in the history
…pport

feat(parser): make named-requests vscode compat
  • Loading branch information
gorillamoe authored Aug 6, 2024
2 parents a56890b + 9c4b144 commit dd62632
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion internal/parser/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ func parseSection(section string, document *Document) Section {
}
lines := strings.Split(section, "\n")
for lineidx, line := range lines {
if line == "" {
if line == "" && !in_body {
if !in_request && !in_body {
in_header = false
in_body = true
Expand Down Expand Up @@ -116,6 +116,11 @@ func documentToString(document Document) string {
for _, comment := range section.Comments {
documentString += comment + "\n"
}
for _, metadata := range section.Metadata {
if strings.HasPrefix(metadata, "# @name ") {
documentString += metadata + "\n"
}
}
documentString += section.Method + " " + section.URL
if section.Version != "" {
documentString += " " + section.Version
Expand All @@ -125,6 +130,9 @@ func documentToString(document Document) string {
documentString += header + "\n"
}
for _, metadata := range section.Metadata {
if strings.HasPrefix(metadata, "# @name ") {
continue
}
documentString += metadata + "\n"
}
if section.Body != "" {
Expand Down

0 comments on commit dd62632

Please sign in to comment.