CodeMirror version 5.62.3 is experiencing some challenges with the scrollbar functionality, editor size, and line wrapping

During my HTML/CSS/JS coding session, I encountered a challenge with CodeMirror version 5.62.3. Specifically, I was striving to make the scrollbar visible in the code editor, using C# as the language mode. However, despite setting the editor's height to 100% for consistency with the HTML document size, the scrollbar appeared static and non-functional. This rendered scrolling impossible, leaving me puzzled.

I speculated if this issue stemmed from an unstable release of CodeMirror or a browser glitch. The problem extended beyond the unresponsive scrollbar to ineffective line wrapping and overall editor sizing discrepancies. Despite consulting various documentation sources, I failed to comprehend CodeMirror\'s functionality fully or find satisfactory solutions.

To aid in diagnosing this complication, I provide the complete HTML page below. Adjustments had been made to hide irrelevant content under the project alias "something".

<!DOCTYPE html>
<html>
    <head>
        <script src="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.62.3/codemirror.min.js"></script>
        <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.62.3/codemirror.min.css">
        <script src="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.62.3/mode/clike/clike.min.js"></script>
        <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.62.3/theme/monokai.min.css">
        <title>something</title>
        <style>
            .CodeMirror {
                line-height: 28px;
                font-family: Lucida Console;
                overflow: auto;
                height: 100%;
            }
        </style>
    </head>
    <body>
        <div id="editor"></div>
        <script>
            var editor = CodeMirror(document.getElementById("editor"), {
      mode: "text/x-csharp",
      lineNumbers: true,
      indentUnit: 4,
      tabSize: 4,
      theme: "monokai",
      lineWrapping: true,
      value: `// Welcome to something!\n// something allows you to test out C# and MSIL online.\n\n// x is supported!\n// You can run x and x for fully free.\n\// You can do so by going into the gear icon on the right.\n\n// something is still in beta!\n// So expect some classes, methods, or properties not yet to be implemented.
      \n// Note: something is not any associated with Microsoft.\n\n// Happy coding! :)\n\nusing System;\n\nnamespace Solution1\n{\n    internal sealed class Program\n    {\n        internal static void Main(string[] args)\n        {\n            Console.WriteLine("Demo test app!");\n            Environment.Exit(0);\n        }\n    }\n}`
    });
    editor.setSize("50%", "100%");
        </script>
    </body>
</html>

Despite efforts, attempts to scroll within the editor yielded no results. To address concerns about my setup, I confirm that I am running Google Chrome version 116 and do not leverage Node.js for operations, opting instead for CDN-based JavaScript libraries.

If anyone can assist or offer suggestions, it would be greatly appreciated.

Sincerely, -winscripter.

Answer №1

After extensive troubleshooting, I was finally able to identify the root cause.

The code snippet in question is:

editor.setSize("50%", "100%");

This implementation is incorrect. Initially, I mistakenly believed that using "100%" would adjust the size according to the HTML document, but that assumption was inaccurate. To achieve the desired outcome, we should utilize 100vh instead:

editor.setSize("50%", "100vh");

Furthermore, it is important to remove the overflow: auto attribute from the CSS.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Obtaining a button from a dialog in Google Apps

It seems like I'm overlooking something really simple here, but I'm struggling to enable an interface button from a dialog box in Google Apps. When I try setting the disabled attribute to false in a this object under the "click" function, the bu ...

I need help with customizing the progress bar in HTML and CSS

How can I create a progress bar like the one shown below: https://i.sstatic.net/BFv87.png .detail-load { height: 42px; border: 1px solid #A2B2C5; padding: 1px; border-radius: 10px; } .detail-load > .detail-loading { ...

Removing a section of HTML from an EmailMessage Body in EWS

Is there a way to remove certain parts of the EWS EmailMessage .Body.Text value in C# before replying with a ResponseMessage? The elements that need to be removed include clickable and non-clickable buttons in HTML format. Since custom tags cannot be dec ...

JavaScript button click changes the selected row's color in a DataTable

I am looking to dynamically change the color of a row in my Datatable when a specific button is clicked. Here is the HTML code snippet for the rows: <tr role="row" class="odd"></tr> <tr role="row" class="even selected"></tr> & ...

Verify the values in the dropdown menu and then cross-reference them with the user's input

Is there a way to verify if the textfield, newTeamName, is already included in a list of teamnames that are stored within a select box? I seem to be encountering issues with my code - can you point out what might be the problem? Just to note, there are no ...

Game Mapping Techniques: Utilizing Spatial Data Structures

In order to efficiently store and retrieve intersecting rectangles, I am currently working on implementing a spatial data structure in JavaScript. My initial approach involves using a Quad Tree to narrow down the search space. However, for dynamic objects ...

What are some creative ways to incorporate images into SVG paths?

Check out my JSFiddle here. I'm attempting to position this image in the center of my arc. My initial thought was to use .attr("fill","url('somePicture')"), but so far, no luck with that approach. const width = 700; const height = 600; con ...

Dynamic content is loaded on the page using AJAX before refreshing to retrieve new

I am using the FullPage.js plugin and attempting to enable navigation between pages using AJAX. While using .load();, I am able to retrieve the desired page. However, it seems that I need to reload fullpage.js since the loaded page is not active and the s ...

The JavaScript Discord Bot is having trouble connecting to a voice channel

I'm currently working on developing a discord bot using node.js. While I've successfully set it up to respond, I'm facing an issue with summoning it to a voice channel. Here is the snippet of code I am working with: switch (args[0]) { c ...

The error message "invalid module name" is preventing Phoenix from creating an HTML template

Encountering issues while trying to run the phx.gen.html templates. Below is the command that I am attempting: mix phx.gen.html Shipments shipmentroutes shipmentroute address:string date:string groups_involved:string An error message is displayed as fol ...

Modifying Ajax-injected HTML with JQuery's editInPlace functionality

I have been successfully using the JQuery editInPlace plug-in on a static HTML page. However, I am facing an issue when trying to use the same plugin with HTML injected via an Ajax call. I have heard that using .on() like '$('.edit_inplace_fiel ...

sliding to the right gets jammed

I am encountering a peculiar issue with Multi-page slide functionality. Whenever I attempt to switch pages, the new page gets stuck on the left before sliding out into position. Feel free to test this problem using my JSFiddle This is the JQuery code that ...

The lower division remains static when the browser window is resized

Why does the div with class .lower not move to the bottom of the page when the screen is resized? Could this be because of its CSS property position:absolute;? Check out the code snippet here. #lower { width: 100%; position: absolute; bot ...

Can you explain the concept of binding and unbinding in jQuery?

Can you explain the concepts of binding and unbinding in jQuery in simple terms for someone who learns slowly? ...

Display information using AngularJS within the Ionic framework

I am attempting to display a variable that is within a for loop. Here is my code where I store the value of $scope.datosTuto[i].Nombre in a variable. When I use an alert to print $scope.NombTuto, I can see the data but I want to display it on my HTML page. ...

Creating unsightly class names using Node.js

Is it possible to automatically create random and unattractive class names? For example, is there a tool or plugin that can substitute the .top-header class with something like .a9ev within my CSS code? It would also be ideal if the class name in the HTML ...

Is there a way to determine the duration that a click was held down for?

When triggering an onClick event, I want to determine whether it was a single click or if the mouse button was held down for some time before releasing. This way, I can call the myTest() function within onClick="myTest()", which will log "mouse was click ...

Encountering an issue while trying to convert a JSON object into an array of a specific class type

When I receive a JSON object from a service, I want to iterate through this object and populate an array of class types. Below is the code used to call the service: public GetMapData(): Observable<Response> { var path = 'http://my.blog.net ...

Is there a datatable available for live data with pagination and search functionality?

I've been experimenting with datatables for real-time data, but I'm facing an issue where the search function doesn't work when my data updates. Additionally, every time I try to paginate, it reverts back to the first page. Does anyone know ...

The JS slider fails to function properly following the migration of AngularJS from version 1.0.8 to 1.2

Seeking assistance with migrating AngularJS from version 1.0.8 to 1.2 and encountering issues with a JavaScript slider that is no longer functioning post-migration... After upgrading to 1.2, added the angular-route.js library and injected 'ngRoute&ap ...