Skip to content

Commit

Permalink
[Feature] support the console auto scroll (DataLinkDC#3255)
Browse files Browse the repository at this point in the history
Co-authored-by: Zzm0809 <Zzm0809@users.noreply.github.com>
  • Loading branch information
Zzm0809 and Zzm0809 authored Mar 7, 2024
1 parent 557384e commit d94b01b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
10 changes: 5 additions & 5 deletions dinky-web/src/components/CustomEditor/CodeShow/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ export type CodeShowFormProps = {
showFloatButton?: boolean;
refreshLogCallback?: () => void;
fullScreenBtn?: boolean;
enableAutoScroll?: boolean;
style?: CSSProperties;
};

Expand Down Expand Up @@ -74,13 +75,12 @@ const CodeShow = (props: CodeShowFormProps) => {
showFloatButton = false,
refreshLogCallback,
fullScreenBtn = false,
enableMiniMap = false
enableMiniMap = false,
enableAutoScroll = false
} = props;

const { ScrollType } = editor;

const [scrollBeyondLastLine] = useState<boolean>(options.scrollBeyondLastLine);

const [loading, setLoading] = useState<boolean>(false);
const [stopping, setStopping] = useState<boolean>(false);
const [autoRefresh, setAutoRefresh] = useState<boolean>(false);
Expand Down Expand Up @@ -180,7 +180,7 @@ const CodeShow = (props: CodeShowFormProps) => {
monacoInstance.current = monaco;
editor.layout();
editor.focus();
if (scrollBeyondLastLine) {
if (enableAutoScroll) {
editor.onDidChangeModelContent(() => {
const lineCount = editor.getModel()?.getLineCount() as number;
if (lineCount > 20) {
Expand Down Expand Up @@ -232,7 +232,7 @@ const CodeShow = (props: CodeShowFormProps) => {
value={code ?? ''}
language={language}
options={{
scrollBeyondLastLine: false,
scrollBeyondLastLine: enableAutoScroll,
readOnly: true,
glyphMargin: false,
wordWrap: autoWrap,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@ const ConsoleContent = (props: ConsoleProps) => {
language={'javalog'}
lineNumbers={'off'}
enableMiniMap
enableAutoScroll
showFloatButton
/>
</Pane>
Expand Down

0 comments on commit d94b01b

Please sign in to comment.