File continuous visual range determination method, electronic equipment and medium
By using binary search and recursive functions to determine the continuous visible range within a file, the problem of discontinuous visible lines in the file is solved, enabling fast and accurate determination of the visible range and improving operational efficiency.
Patent Information
- Application Number
- CN202511309807.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-09-15
- Publication Date
- 2025-10-17
- Estimated Expiration
- 2045-09-15
AI Technical Summary
In existing technologies, the visible lines within a file are not necessarily continuous, making it difficult to accurately and quickly determine the continuous visible range in large files, which affects the efficiency of lexical highlighting and debugging operations.
By employing a binary search method combined with a recursive function, the system obtains the start and end visible line numbers, file line numbers, and identifier file line numbers to determine all folded lines within the visible range to be processed and stores them in a continuous visible range set, thus achieving fast and accurate determination of the continuous visible range.
It improves the accuracy and speed of determining continuous visible ranges from high-volume files, and enhances the efficiency of lexical highlighting and debugging operations.
Smart Images

Figure CN120803597A_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of computer, in particular to a file continuous visible range determination method, an electronic device and a medium. BACKGROUND
[0002] In the process of software development, the code written in a file is usually composed of code blocks with certain hierarchical structure, for example, a loop statement can be contained in a function, and a function can be contained in a larger module (such as a class or a file), and the above various statement blocks can also contain comment information, and single-line or continuous multi-line comment information can also be regarded as a statement block. In order to improve the reading convenience of users for the same code block, the existing editor usually provides folding and unfolding functions to display as much content as possible that users care about on a fixed-size display screen. The source code file line after folding will not be visible, which is usually referred to as invisible line, and vice versa, which is visible line.
[0003] In actual application scenarios, the number of visible lines on the display is relatively small and constant, but due to the existence of the folding function, these visible lines are not necessarily continuous, and there can be a large number of invisible lines interspersed. For example: in a design, when folding ten thousand lines or even millions of lines of code. At this time, the span of the file lines in the visible range will be greater than one million lines, and the actual visible line number can only be tens of lines. In actual business scenarios, if lexical highlighting, signal marking, debugging, etc. are needed, for performance considerations, it is often necessary to highlight the code in the continuous visible range of the corresponding file first. Therefore, how to accurately and quickly determine the continuous visible range from the continuous file with high order of magnitude becomes a technical problem to be solved. SUMMARY
[0004] The present application aims to provide a file continuous visible range determination method, an electronic device and a medium, which can accurately and quickly determine the continuous visible range from the continuous file with high order of magnitude.
[0005] According to the first aspect of the present application, a file continuous visible range determination method is provided, comprising: Step S1, initially setting the continuous visible range set as empty; Step S2, obtaining the file start visible line number SV in the to-be-processed visible range and the file end visible line number EV in the to-be-processed visible range; Step S3, obtaining the file line number SF corresponding to SV and the file line number EF corresponding to EV; Step S4, initially setting the identification file line number GF = SF, which is used to identify the starting file line of the current continuous visible range to be determined; Step S5, if EF-SF=EV-SV, then execute step S6, otherwise execute step S7; Step S6, determine {SF, EF} as the continuous visible range, store it into the continuous visible range set, and end the process. Step S7, based on the file start visible line number SV, the file end visible line number EV, the file line number SF, the file line number EF, and the identification file line number GF, use the binary search method to obtain all the fold lines in the to-be-processed visible range, and store all the continuous visible ranges in the continuous visible range set.
[0006] According to a second aspect of the present application, an electronic device is provided, comprising: at least one processor; and a memory connected in communication with the at least one processor; wherein the memory stores instructions executed by the at least one processor, and the instructions are configured to execute the method according to the first aspect of the present application.
[0007] According to a third aspect of the present application, a computer readable storage medium is provided, which stores computer executable instructions, and the computer executable instructions are used to execute the method according to the first aspect of the present application.
[0008] Compared with the prior art, the present application has obvious advantages and beneficial effects. By means of the above technical scheme, the file continuous visible range determination method, the electronic device and the medium provided by the present application can achieve considerable technical progress and practicability, and have wide industrial utilization value. At least the following beneficial effects are achieved: The present application first obtains the file start visible line number SV, the file end visible line number EV, the file line number SF, the file line number EF, and the identification file line number GF, and then based on the binary search method, all the fold lines in the to-be-processed visible range are obtained, and all the continuous visible ranges are stored in the continuous visible range set, so that the continuous visible range is accurately and quickly determined from the continuous file with a high number of orders, and the operation speed of the visible line is improved. BRIEF DESCRIPTION OF DRAWINGS
[0009] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings needed in the embodiment description will be briefly introduced. Obviously, the drawings in the following description are only some embodiments of the present application, and other drawings can be obtained by those skilled in the art without creative labor.
[0010] Figure 1 A file continuous visible range determination method provided by the embodiment of the present application is shown in the figure. Figure 2 A to-be-processed visible range file line number provided by the embodiment of the present application is shown in the figure. DETAILED DESCRIPTION
[0011] The following will clearly and completely describe the technical solutions in the embodiments of the present invention in conjunction with the accompanying drawings. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without making any creative efforts shall fall within the scope of protection of the present invention.
[0012] The embodiment of the present invention provides a method for determining a continuous visible range of a file. Figure 1 Shown, including: Step S1: Initially set the continuous visible range set to be empty.
[0013] The continuous visible range set is used to store the continuous visible ranges determined from the visible range to be processed from top to bottom. The file line numbers increase from top to bottom within the visible range, and the visible line numbers increase from top to bottom.
[0014] Step S2: Obtain the file's starting visible line number SV and the file's ending visible line number EV within the visible range to be processed.
[0015] It should be noted that the visible line numbers are continuous, but since there are folded lines in the visible range, the file line numbers are not necessarily continuous.
[0016] Step S3: Obtain the file line number SF corresponding to SV and the file line number EF corresponding to EV.
[0017] like Figure 2 In the visible range to be processed, the file line number SF corresponding to the file starting line number SV is 105, and the file line number EF corresponding to the file ending line number EV is 200023. There are four folds in the visible range to be processed. The first fold corresponds to line number 109, the second fold corresponds to line number 910, the third fold corresponds to line number 3405, and the fourth fold corresponds to line number 98009.
[0018] Step S4: Initially set the identification file line number GF=SF, where the identification file line number is used to identify the starting file line of the continuous visible range to be determined.
[0019] It should be noted that the embodiment of the present invention divides the continuous visual range in the order of the visual range to be processed from top to bottom, so the identification file line number GF is dynamically changed. In the initial case, GF=SF. Figure 2In the shown example, when the first continuous view range {105, 109} is cut out, GF is updated to 905.
[0020] In step S5, if EF-SF=EV-SV, step S6 is performed, otherwise step S7 is performed.
[0021] It should be noted that if EF-SF=EV-SV, it means that there is no folding line in the to-be-processed view range, and step S6 is directly entered to determine {SF, EF} as the continuous view range. If there is a folding line, step S7 is entered to determine the folding line one by one to determine all continuous view ranges.
[0022] In step S6, {SF, EF} is determined as the continuous view range and stored in the continuous view range set, and the process ends.
[0023] In step S7, all folding lines in the to-be-processed view range are obtained by using binary search based on the file start view line number SV, the file end view line number EV, the file line number SF, the file line number EF, and the identification file line number GF, and all continuous view ranges are stored in the continuous view range set.
[0024] It should be noted that the binary search combined with the dynamically changing GF can accurately and quickly determine all folding lines in the to-be-processed view range, and improve the determination efficiency and accuracy of the continuous view range in the to-be-processed view range.
[0025] As an embodiment, in step S3, the file line number SF corresponding to SV and the file line number EF corresponding to EV are obtained based on the preset file line number and view line number mapping table. The preset mapping relationship between the file line number and the view line number can be obtained in advance and stored in the file line number and view line number mapping table.
[0026] As an embodiment, step S7 includes: In step S71, the first input parameter A1=SV, the second input parameter A2=EV, the third input parameter A3=SF, and the fourth input parameter A4=EF are set, a preset folding line searching function is called based on {A1, A2, A3, A4} to find all folding lines in the to-be-processed view range from top to bottom by binary search, and all continuous regions except the last continuous region are determined. After the preset folding line searching function call is completely ended, GF has been updated to the start file line of the last continuous view range, and the preset folding line searching function is a recursive function generated based on binary search.
[0027] Wherein, A1, A2, A3, A4 are inputs of the preset folded row lookup function. It can be understood that the preset folded row lookup function is a recursive function generated based on binary search method, thus the preset folded row lookup function is continuously called inside the preset folded row lookup function.
[0028] Step S72, determining {GF, EF} as the last A3.
[0029] As an embodiment, the preset folded row lookup function comprises: Step S10, inputting {A1, A2, A3, A4} into the preset folded row lookup function, if A2-A1>1, executing step S20, otherwise, executing step S80.
[0030] Step S20, setting the intermediate visible row line number MV=(A1+A2+1) / 2.
[0031] It should be noted that setting MV=(A1+A2+1) / 2 can ensure that the intermediate visible row line number MV is necessarily down each time, further improving the efficiency of folded row lookup on the basis of ensuring correctness.
[0032] Step S30, obtaining the file line number MF corresponding to MV.
[0033] Wherein, the file line number MF corresponding to MV is specifically obtained based on the preset file line number and visible line number mapping table. The preset mapping relationship between the file line number and the visible line number can be obtained in advance and stored in the file line number and visible line number mapping table.
[0034] Step S40, if MF-A3=MV-A1, executing step S60, otherwise, executing step S50.
[0035] Step S50, setting A1=A1, A2=MV, A3=A3, A4=MF, calling the preset folded row lookup function based on {A1, A2, A3, A4}, after the function call ends, executing step S60.
[0036] It should be noted that step S50 re-calls the preset folded row lookup function inside the preset folded row lookup function based on the updated {A1, A2, A3, A4}.
[0037] Step S60, if A4-MF=A2-MV, ending the function call, otherwise, executing step S70.
[0038] Step S70, setting A1=MV, A2=A2, A3=MF, A4=A4, calling the preset folded row lookup function based on {A1, A2, A3, A4}, after the processing ends, ending the function call.
[0039] It should be noted that step S70 re-invokes the preset folding line search function based on the updated {A1, A2, A3, A4} inside the preset folding line search function.
[0040] Step S80, determine the behavior folding line corresponding to A3, determine {GF, A3} as the continuous viewable range, and store it in the continuous viewable range set.
[0041] It should be noted that when A2-A1≤1, step S80 is entered, which means that the viewable behavior lines corresponding to A2 and A1 are adjacent or the same line, at this time, it can be determined that the file line number A3 corresponding to A1 is the folding line, and GF is the starting file line of the current continuous viewable range to be determined, therefore, {GF, A3} is determined as the continuous viewable range. At present, A4 corresponding to A2 is the starting file line of the next continuous viewable range to be determined, therefore, GF=A4 is updated through step S90.
[0042] Step S90, update GF=A4, end function call.
[0043] It should be noted that the preset folding line search function implemented through steps S10-S80 is constructed based on the bisection method and the recursive function in the embodiment of the application, and each folding line of the viewable range to be processed is accurately and quickly determined from top to bottom by directly or directly or indirectly calling the preset folding line search function inside the function, so as to determine each continuous viewable range in the viewable range to be processed, which facilitates subsequent execution of lexical highlighting, signal marking, debugging and other operations based on each continuous viewable range.
[0044] In addition, in the above example, steps S10-S80 are executed in series, that is, the continuous viewable ranges are cut out from the viewable range to be processed in strict accordance with the order from top to bottom of the viewable range to be processed. However, it can be understood that for each group {A1, A2, A3, A4} calling the preset folding line search function, it is equivalent to judging whether the code lines between the viewable line A1 and the viewable line A2 are continuous or not, whether they need to be further divided into two parts for further judgment, if they need to be cut, and the two parts after cutting can be executed in parallel, but the process involving the execution of step S80, determining the behavior folding line corresponding to A3, determining {GF, A3} as the continuous viewable range, and storing it in the continuous viewable range set, can be strictly executed in series. The parallel and serial execution mode can further improve the efficiency of determining the continuous viewable range while ensuring the accuracy of determining the continuous viewable range of the file.
[0045] It should be noted that, in order to further ensure the accuracy of the file continuous visible range determination, in the step S30, the preset folding line search function further comprises: a step S00 arranged before the step S10, if A4-A3=A2-A1, the function call is ended, otherwise, the step S10 is executed. It should be noted that the calling condition of the preset folding line search function has actually filtered out the case of A4-A3=A2-A1, and by setting S00, it can further detect whether the case of A4-A3=A2-A1 misfires the preset folding line search function, and further improve the accuracy of the file continuous visible range determination.
[0046] The embodiment of the application first acquires a file start visible line number SV, a file end visible line number EV, a file line number SF, a file line number EF, and an identification file line number GF, and then acquires all folding lines in a to-be-processed visible range based on a binary search method, and stores all continuous visible ranges in the continuous visible range set, so that the continuous visible range is accurately and quickly determined from a continuous file with a high order of magnitude, and the operation speed of the visible line is improved.
[0047] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this application belongs. The terminology used in the description herein is for describing specific embodiments only and is not intended to be limiting. As used in this description, the term "and / or" includes any and all combinations of one or more of the associated listed items.
[0048] It should be noted that some example embodiments are described as processes or methods that are depicted as flow diagrams. Although the processes are described in a particular sequential order, many of the processes can be performed concurrently, in parallel, or simultaneously. In addition, the order of the processes can be re-arranged. The processes can terminate when their functions are completed, but can also have additional steps not included in the figure. The processes can correspond to methods, functions, procedures, subroutines, subprograms, etc.
[0049] The embodiment of the application further provides an electronic device, comprising: at least one processor; and a memory in communication connection with the at least one processor; wherein the memory stores instructions executed by the at least one processor, and the instructions are arranged to execute the method provided by the embodiment of the application.
[0050] The embodiment of the application further provides a computer readable storage medium, which stores computer executable instructions, and the computer executable instructions are used for executing the method provided by the embodiment of the application.
[0051] The above merely describes preferred embodiments of the present application, and is not intended to limit the present application in any form. Although the present application has been disclosed with the preferred embodiments as above, it is not intended to limit the present application. Any person skilled in the art, without departing from the technical solution of the present application, can make some changes or modifications to the above disclosed technical content to obtain equivalent embodiments with equivalent changes. However, any simple modification, equivalent change and modification made to the above embodiments according to the technical essence of the present application, as long as it does not deviate from the technical solution of the present application, still belongs to the scope of the technical solution of the present application.
Claims
1. A method for determining a continuous visible range of a file, characterized in that: include: Step S1: Initially set the continuous visual range set to be empty; Step S2, obtaining the file's starting visible line number SV and the file's ending visible line number EV within the visible range to be processed; Step S3, obtaining the file line number SF corresponding to SV and the file line number EF corresponding to EV; Step S4: Initially set the identification file line number GF=SF, where the identification file line number is used to identify the starting file line of the continuous visible range to be determined; Step S5: If EF-SF = EV-SV, go to step S6; otherwise, go to step S7; Step S6: Determine {SF, EF} as a continuous visible range, store it in the continuous visible range set, and end the process; Step S7: Based on the file start visible line number SV, the end visible line number EV, the file line number SF, the file line number EF, and the identification file line number GF, a binary search method is used to obtain all folded lines in the visible range to be processed, and all continuous visible ranges are stored in the continuous visible range set.
2. The method according to claim 1, characterized in that In step S3, the file line number SF corresponding to SV and the file line number EF corresponding to EV are obtained based on a preset mapping table of file line numbers and visible line numbers.
3. The method according to claim 1, characterized in that The step S7 comprises: Step S71: Set the first input parameter A1=SV, the second input parameter A2=EV, the third input parameter A3=SF, and the fourth input parameter A4=EF. Based on {A1, A2, A3, A4}, call a preset folding line search function to perform a binary search from top to bottom to find all folding lines within the visible range to be processed, and determine all continuous areas except the last continuous area. After the call of the preset folding line search function is completed, GF has been updated to the starting file line of the last continuous visible range. The preset folding line search function is a recursive function generated based on a binary search method. Step S72: Determine {GF, EF} as the last A3.
4. The method according to claim 3, characterized in that The preset folded row search function includes: Step S10: Input {A1, A2, A3, A4} into the preset folded row search function. If A2-A1>1, execute step S20; otherwise, execute step S80. Step S20: Set the middle visible row number MV = (A1+A2+1) / 2; Step S30, obtaining the file line number MF corresponding to MV; Step S40: If MF-A3 = MV-A1, proceed to step S60; otherwise, proceed to step S50; Step S50: Set A1=A1, A2=MV, A3=A3, A4=MF, and call the preset folded row search function based on {A1, A2, A3, A4}. After the function call is completed, execute step S60; Step S60: If A4-MF=A2-MV, then end the function call; otherwise, go to step S70; Step S70: Set A1=MV, A2=A2, A3=MF, A4=A4, and call the preset folded row search function based on {A1, A2, A3, A4}. After the processing is completed, end the function call; Step S80: Determine that the row corresponding to A3 is a folded row, determine {GF, A3} as a continuous visible range, and store it in the continuous visible range set; Step S90: Update GF=A4 and end the function call.
5. The method according to claim 4, characterized in that In step S30, the file line number MF corresponding to MV is obtained based on a preset mapping table of file line numbers and visible line numbers.
6. The method according to claim 4, characterized in that The preset folded row search function also includes: Set step S00 before step S10, if A4-A3=A2-A1, end the function call, otherwise, execute step S10.
7. An electronic device, characterized in that: include: at least one processor; and, a memory communicatively coupled to the at least one processor; The memory stores instructions to be executed by the at least one processor, wherein the instructions are configured to execute the method according to any one of claims 1 to 6.
8. A computer-readable storage medium, characterized in that The computer-executable instructions are stored, and the computer-executable instructions are used to execute the method according to any one of the preceding claims 1 to 6.
Citation Information
Patent Citations
Multiple row header areas and / or multiple column header areas for display in summary table
CN102317931A
Method and device for processing session information
CN112684961A
Information searching method and device, server, readable storage medium and program product
CN113110944A
Page generation method, page generation equipment and computer readable storage medium
CN116821448A
Method and device for constructing parent and child documents of express order and electronic equipment
CN117216075A