microsoft / microsoft/monaco-editor

Editor text is centered instead of left

Open
#4,505 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
46.8k
Forks
4.1k
Avg merge
17h 58m
Merged PRs (30d)
1

Description

Reproducible in vscode.dev or in VS Code Desktop?
  • Not reproducible in vscode.dev or VS Code Desktop
Reproducible in the monaco editor playground?
Monaco Editor Playground Link

The above is the code that caused the problem

Monaco Editor Playground Code
<template>
    <el-drawer v-model="drawerVisable" direction="rtl" size="100%">
            <span>输入</span>
            <div class="editor" ref="aceInputRef"></div>
    </el-drawer>
</template>

<script setup lang="ts">
import { ref, computed, defineEmits, defineProps, defineExpose, nextTick, watch, onMounted } from "vue";
import * as monaco from 'monaco-editor/esm/vs/editor/editor.api.js';
// import * as monaco from 'monaco-editor';
import { MonacoBreakpoint } from 'monaco-breakpoints';

const props = defineProps(['statusList']);
const emit = defineEmits(['sendSocket', 'clearSelect']);

const drawerVisable = ref(true);
const aceInputRef = ref<any>();
const editorInput = ref(null);

onMounted(() => {
    nextTick(() => {
        const editor:any = monaco.editor.create(aceInputRef.value, {
            value: [
	'function foo() {\n',
	'\treturn 1;\n',
	'}\n',
	'function bar() {\n',
	'\treturn 1;\n',
	'}',
].join(''),
            language: "vb",
            automaticLayout: true,
            minimap: {
                enabled: false,
            },
            glyphMargin: true, // 启用图形边距渲染
            folding: true, // 折叠
            theme: "vs",
        })
        
        const instance = new MonacoBreakpoint({ editor });

        
        instance.on('breakpointChanged', breakpoints => {
            console.log('breakpointChanged: ', breakpoints); // 获取有断点的行数
            console.log(editor.getModel().getLinesContent(),'11'); // 获取全部代码以数组形式区分行数
            console.log(editor.getModel().getLineContent(2),'22'); // 获取第二行代码
        })
    })
})

</script>

<style>
.editor {
    width: 100%;
    height: 500px;
}
</style>
Reproduction Steps

The above is the code that caused the problem

Actual (Problematic) Behavior

Editor text is centered instead of left

Expected Behavior

Editor text is centered left instead of centered

Additional Context
"monaco-breakpoints": "^0.1.2",
"monaco-editor": "^0.48.0",
"monaco-editor-webpack-plugin": "^7.1.0",
"terser-webpack-plugin": "^5.3.10",
"vue": "^3.2.13",
"vue-router": "^4.0.3",
"node": 14

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the supplied Vue code and the monaco.editor.create configuration, especially the editor container and layout options. Reproduce the centered text using the provided dependencies and compare the result with the expected left-aligned editor text; done means the minimal reproduction renders text left-aligned.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, typescript
Domain
frontend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.