mirror of
https://github.com/windmill-labs/windmill.git
synced 2026-09-06 08:01:35 +00:00
fix: reset with minimal code (#1982)
This commit is contained in:
@@ -34,12 +34,6 @@
|
||||
langToExt,
|
||||
updateOptions
|
||||
} from '$lib/editorUtils'
|
||||
import {
|
||||
BASH_INIT_CODE,
|
||||
DENO_INIT_CODE_CLEAR,
|
||||
GO_INIT_CODE,
|
||||
PYTHON_INIT_CODE_CLEAR
|
||||
} from '$lib/script_helpers'
|
||||
import type { Disposable } from 'vscode'
|
||||
import type { DocumentUri, MessageTransports } from 'vscode-languageclient'
|
||||
import { dirtyStore } from './common/confirmationModal/dirtyStore'
|
||||
@@ -200,20 +194,6 @@
|
||||
}
|
||||
}
|
||||
|
||||
export async function clearContent() {
|
||||
if (editor) {
|
||||
if (lang == 'typescript') {
|
||||
setCode(DENO_INIT_CODE_CLEAR)
|
||||
} else if (lang == 'python') {
|
||||
setCode(PYTHON_INIT_CODE_CLEAR)
|
||||
} else if (lang == 'go') {
|
||||
setCode(GO_INIT_CODE)
|
||||
} else if (lang == 'shell') {
|
||||
setCode(BASH_INIT_CODE)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let command: Disposable | undefined = undefined
|
||||
|
||||
let dbSchemaCompletor: Disposable | undefined = undefined
|
||||
|
||||
@@ -39,7 +39,7 @@
|
||||
import ScriptVersionHistory from './ScriptVersionHistory.svelte'
|
||||
import { ScriptGen } from './codeGen'
|
||||
import type DiffEditor from './DiffEditor.svelte'
|
||||
import { initialCode } from '$lib/script_helpers'
|
||||
import { getResetCode } from '$lib/script_helpers'
|
||||
import type { Script } from '$lib/gen'
|
||||
|
||||
export let lang: SupportedLanguage
|
||||
@@ -180,7 +180,7 @@
|
||||
|
||||
function clearContent() {
|
||||
if (editor) {
|
||||
const resetCode = initialCode(lang, kind as Script.kind, template)
|
||||
const resetCode = getResetCode(lang, kind as Script.kind, template)
|
||||
editor.setCode(resetCode)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -349,3 +349,19 @@ export function initialCode(
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export function getResetCode(
|
||||
language: SupportedLanguage,
|
||||
kind: Script.kind | undefined,
|
||||
subkind: 'pgsql' | 'mysql' | 'flow' | 'script' | 'fetch' | 'docker' | 'powershell' | undefined
|
||||
) {
|
||||
if (language === 'deno') {
|
||||
return DENO_INIT_CODE_CLEAR
|
||||
} else if (language === 'python3') {
|
||||
return PYTHON_INIT_CODE_CLEAR
|
||||
} else if (language === 'bun') {
|
||||
return BUN_INIT_CODE_CLEAR
|
||||
} else {
|
||||
return initialCode(language, kind, subkind)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user