mirror of
https://github.com/windmill-labs/windmill.git
synced 2026-08-21 08:02:26 +00:00
fix(frontend): go editor nits
This commit is contained in:
@@ -32,7 +32,12 @@
|
||||
|
||||
import getMessageServiceOverride from 'vscode/service-override/messages'
|
||||
import { StandaloneServices } from 'vscode/services'
|
||||
import { DENO_INIT_CODE_CLEAR, PYTHON_INIT_CODE_CLEAR } from '$lib/script_helpers'
|
||||
import {
|
||||
DENO_INIT_CODE,
|
||||
DENO_INIT_CODE_CLEAR,
|
||||
GO_INIT_CODE,
|
||||
PYTHON_INIT_CODE_CLEAR
|
||||
} from '$lib/script_helpers'
|
||||
import {
|
||||
createHash as randomHash,
|
||||
editorConfig,
|
||||
@@ -109,6 +114,14 @@
|
||||
}
|
||||
}
|
||||
|
||||
export function insertAtLine(code: string, line: number): void {
|
||||
if (editor) {
|
||||
const range = { startLineNumber: line, startColumn: 1, endLineNumber: line, endColumn: 1 }
|
||||
const op = { range: range, text: code, forceMoveMarkers: true }
|
||||
editor.executeEdits('external', [op])
|
||||
}
|
||||
}
|
||||
|
||||
export function setCode(ncode: string): void {
|
||||
code = ncode
|
||||
if (editor) {
|
||||
@@ -132,8 +145,8 @@
|
||||
setCode(DENO_INIT_CODE_CLEAR)
|
||||
} else if (lang == 'python') {
|
||||
setCode(PYTHON_INIT_CODE_CLEAR)
|
||||
} else {
|
||||
setCode('')
|
||||
} else if (lang == 'go') {
|
||||
setCode(GO_INIT_CODE)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -130,7 +130,7 @@
|
||||
editor.insertAtCursor(`wmill.get_variable("${path}")`)
|
||||
} else if (lang == 'go') {
|
||||
if (!editor.getCode().includes('wmill "github.com/windmill-labs/windmill-go-client"')) {
|
||||
editor.insertAtBeginning('import wmill "github.com/windmill-labs/windmill-go-client"\n')
|
||||
editor.insertAtLine('import wmill "github.com/windmill-labs/windmill-go-client"\n\n', 3)
|
||||
}
|
||||
editor.insertAtCursor(`v, _ := wmill.GetVariable("${path}")`)
|
||||
}
|
||||
@@ -174,7 +174,7 @@
|
||||
editor.insertAtCursor(`wmill.get_resource("${path}")`)
|
||||
} else if (lang == 'go') {
|
||||
if (!editor.getCode().includes('wmill "github.com/windmill-labs/windmill-go-client"')) {
|
||||
editor.insertAtBeginning('import wmill "github.com/windmill-labs/windmill-go-client"\n')
|
||||
editor.insertAtLine('import wmill "github.com/windmill-labs/windmill-go-client"\n\n', 3)
|
||||
}
|
||||
editor.insertAtCursor(`r, _ := wmill.GetResource("${path}")`)
|
||||
}
|
||||
|
||||
@@ -64,7 +64,9 @@ import (
|
||||
// wmill "github.com/windmill-labs/windmill-go-client"
|
||||
)
|
||||
|
||||
func main(x string, nested struct{ Foo string \`json:"bar"\` }) (interface{}, error) {
|
||||
// the main must return (interface{}, error)
|
||||
|
||||
func main(x string, nested struct{ Foo string \`json:"foo"\` }) (interface{}, error) {
|
||||
fmt.Println("Hello, World")
|
||||
fmt.Println(nested.Foo)
|
||||
fmt.Println(quote.Opt())
|
||||
|
||||
Reference in New Issue
Block a user