Unverified Commit d94b01b5 authored by Zzm0809's avatar Zzm0809 Committed by GitHub

[Feature] support the console auto scroll (#3255)

parent 557384e6
...@@ -46,6 +46,7 @@ export type CodeShowFormProps = { ...@@ -46,6 +46,7 @@ export type CodeShowFormProps = {
showFloatButton?: boolean; showFloatButton?: boolean;
refreshLogCallback?: () => void; refreshLogCallback?: () => void;
fullScreenBtn?: boolean; fullScreenBtn?: boolean;
enableAutoScroll?: boolean;
style?: CSSProperties; style?: CSSProperties;
}; };
...@@ -74,13 +75,12 @@ const CodeShow = (props: CodeShowFormProps) => { ...@@ -74,13 +75,12 @@ const CodeShow = (props: CodeShowFormProps) => {
showFloatButton = false, showFloatButton = false,
refreshLogCallback, refreshLogCallback,
fullScreenBtn = false, fullScreenBtn = false,
enableMiniMap = false enableMiniMap = false,
enableAutoScroll = false
} = props; } = props;
const { ScrollType } = editor; const { ScrollType } = editor;
const [scrollBeyondLastLine] = useState<boolean>(options.scrollBeyondLastLine);
const [loading, setLoading] = useState<boolean>(false); const [loading, setLoading] = useState<boolean>(false);
const [stopping, setStopping] = useState<boolean>(false); const [stopping, setStopping] = useState<boolean>(false);
const [autoRefresh, setAutoRefresh] = useState<boolean>(false); const [autoRefresh, setAutoRefresh] = useState<boolean>(false);
...@@ -180,7 +180,7 @@ const CodeShow = (props: CodeShowFormProps) => { ...@@ -180,7 +180,7 @@ const CodeShow = (props: CodeShowFormProps) => {
monacoInstance.current = monaco; monacoInstance.current = monaco;
editor.layout(); editor.layout();
editor.focus(); editor.focus();
if (scrollBeyondLastLine) { if (enableAutoScroll) {
editor.onDidChangeModelContent(() => { editor.onDidChangeModelContent(() => {
const lineCount = editor.getModel()?.getLineCount() as number; const lineCount = editor.getModel()?.getLineCount() as number;
if (lineCount > 20) { if (lineCount > 20) {
...@@ -232,7 +232,7 @@ const CodeShow = (props: CodeShowFormProps) => { ...@@ -232,7 +232,7 @@ const CodeShow = (props: CodeShowFormProps) => {
value={code ?? ''} value={code ?? ''}
language={language} language={language}
options={{ options={{
scrollBeyondLastLine: false, scrollBeyondLastLine: enableAutoScroll,
readOnly: true, readOnly: true,
glyphMargin: false, glyphMargin: false,
wordWrap: autoWrap, wordWrap: autoWrap,
......
...@@ -183,6 +183,7 @@ const ConsoleContent = (props: ConsoleProps) => { ...@@ -183,6 +183,7 @@ const ConsoleContent = (props: ConsoleProps) => {
language={'javalog'} language={'javalog'}
lineNumbers={'off'} lineNumbers={'off'}
enableMiniMap enableMiniMap
enableAutoScroll
showFloatButton showFloatButton
/> />
</Pane> </Pane>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment