Skip to content

Commit

Permalink
Merge pull request #56 from onflow/ls/bugfix/windows-path
Browse files Browse the repository at this point in the history
[LS] Strip extra slash on windows paths
  • Loading branch information
sideninja authored Jan 5, 2023
2 parents 151e8fd + da811fc commit b079606
Showing 1 changed file with 16 additions and 9 deletions.
25 changes: 16 additions & 9 deletions languageserver/integration/commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
"encoding/json"
"fmt"
"net/url"
"strings"

"github.com/onflow/flow-cli/pkg/flowkit"
"github.com/onflow/flow-go-sdk"
Expand Down Expand Up @@ -75,9 +76,9 @@ func (c *commands) getAll() []server.Command {
// source document in VS Code.
//
// There should be exactly 3 arguments:
// * the DocumentURI of the file to submit
// * the arguments, encoded as JSON-CDC
// * the signer names as list
// - the DocumentURI of the file to submit
// - the arguments, encoded as JSON-CDC
// - the signer names as list
func (c *commands) sendTransaction(args ...json.RawMessage) (any, error) {
err := server.CheckCommandArgumentCount(args, 3)
if err != nil {
Expand Down Expand Up @@ -132,8 +133,8 @@ func (c *commands) sendTransaction(args ...json.RawMessage) (any, error) {
// executeScript handles executing a script defined in the source document.
//
// There should be exactly 2 arguments:
// * the DocumentURI of the file to submit
// * the arguments, encoded as JSON-CDC
// - the DocumentURI of the file to submit
// - the arguments, encoded as JSON-CDC
func (c *commands) executeScript(args ...json.RawMessage) (any, error) {
err := server.CheckCommandArgumentCount(args, 2)
if err != nil {
Expand Down Expand Up @@ -168,7 +169,7 @@ func (c *commands) executeScript(args ...json.RawMessage) (any, error) {
// when submitting transactions.
//
// There should be 1 argument:
// * name of the new active account
// - name of the new active account
func (c *commands) switchActiveAccount(args ...json.RawMessage) (any, error) {
err := server.CheckCommandArgumentCount(args, 1)
if err != nil {
Expand Down Expand Up @@ -208,9 +209,9 @@ func (c *commands) createAccount(_ ...json.RawMessage) (any, error) {
// file.
//
// There should be exactly 3 arguments:
// * the DocumentURI of the file to submit
// * the name of the contract
// * the signer names as list
// - the DocumentURI of the file to submit
// - the name of the contract
// - the signer names as list
func (c *commands) deployContract(args ...json.RawMessage) (any, error) {
err := server.CheckCommandArgumentCount(args, 3)
if err != nil {
Expand Down Expand Up @@ -264,5 +265,11 @@ func parseLocation(arg []byte) (*url.URL, error) {
return nil, fmt.Errorf("invalid path argument: %s", uri)
}

// workaround for Windows files being sent with prefixed '/' which is /c:/test/foo
// we remove the first / for Windows files, so they are valid
if strings.Contains(location.Path, ":") {
location.Path = location.Path[1:]
}

return location, nil
}

0 comments on commit b079606

Please sign in to comment.