Skip to content

Commit 76c3ef6

Browse files
committed
Long lines cause slow syntax highlighting and VS Code to hang
Fixes #309 Fixes again #207 but without using non-fixed width look behinds
1 parent b9079c9 commit 76c3ef6

File tree

4 files changed

+811
-8
lines changed

4 files changed

+811
-8
lines changed

CHANGELOG.md

+3
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
1111

1212
### Fixed
1313

14+
- Fixed slow performance of very long lines by using a different solution for
15+
([#207](https://github.com/fortran-lang/vscode-fortran-support/issues/207))
16+
([#309](https://github.com/fortran-lang/vscode-fortran-support/issues/309))
1417
- Fixed hovering over user defined types while debugging
1518
([#426](https://github.com/fortran-lang/vscode-fortran-support/issues/426))
1619
- Fixes linting regex to capture a wider spectrum of errors

syntaxes/fortran_free-form.tmLanguage.json

+7-8
Original file line numberDiff line numberDiff line change
@@ -2543,7 +2543,7 @@
25432543
"derived-type-component-type-specification": {
25442544
"comment": "Introduced in the Fortran 1995 standard.",
25452545
"name": "meta.specification.derived-type.fortran",
2546-
"begin": "(?ix)(?=\\b(?:character|class|complex|double\\s*precision|double\\s*complex|integer|logical|real|type)\\b(?![^'\";!\\n]*(?<!\\(\\s*|::\\s*)\\bfunction\\b))",
2546+
"begin": "(?ix)(?=\\b(?:character|class|complex|double\\s*precision|double\\s*complex|integer|logical|real|type)\\b(?![^:'\";!\\n]*\\bfunction\\b))",
25472547
"end": "(?=[;!\\n])",
25482548
"patterns": [
25492549
{
@@ -4010,8 +4010,7 @@
40104010
"function-definition": {
40114011
"comment": "Function program unit. Introduced in the Fortran 1977 standard.",
40124012
"name": "meta.function.fortran",
4013-
"comment2": "Escape :: ( , if they are before function. These are non-fixed width lookbehinds but they seem to work",
4014-
"begin": "(?i)(?=([^'\";!\\n](?!\\bend))*(?:(?<!\\(\\s*|::\\s*|,\\s*))\\bfunction\\b)",
4013+
"begin": "(?i)(?=([^:'\";!\\n](?!\\bend)(?!\\bsubroutine\\b))*\\bfunction\\b)",
40154014
"end": "(?=[;!\\n])",
40164015
"patterns": [
40174016
{
@@ -4094,8 +4093,8 @@
40944093
{
40954094
"comment": "Specification and execution block.",
40964095
"name": "meta.block.specification.function.fortran",
4097-
"begin": "(?i)(?!(?:end\\s*[;!\\n]|end\\s*function\\b))",
4098-
"end": "(?i)(?=(?:end\\s*[;!\\n]|end\\s*function\\b))",
4096+
"begin": "(?i)(?!\\b(?:end\\s*[;!\\n]|end\\s*function\\b))",
4097+
"end": "(?i)(?=\\b(?:end\\s*[;!\\n]|end\\s*function\\b))",
40994098
"patterns": [
41004099
{
41014100
"comment": "Contains block.",
@@ -4106,7 +4105,7 @@
41064105
"name": "keyword.control.contains.fortran"
41074106
}
41084107
},
4109-
"end": "(?i)(?=\\s*(?:end\\s*[;!\\n]|end\\s*function\\b))",
4108+
"end": "(?i)(?=(?:end\\s*[;!\\n]|end\\s*function\\b))",
41104109
"patterns": [
41114110
{
41124111
"include": "$base"
@@ -4350,7 +4349,7 @@
43504349
"subroutine-definition": {
43514350
"comment": "Subroutine program unit. Introduced in the Fortran 1977 standard.",
43524351
"name": "meta.subroutine.fortran",
4353-
"begin": "(?i)(?=([^'\";!\\n](?!\\bend))*(?:(?<!::\\s*))\\bsubroutine\\b)",
4352+
"begin": "(?i)(?=([^:'\";!\\n](?!\\bend))*\\bsubroutine\\b)",
43544353
"end": "(?=[;!\\n])",
43554354
"patterns": [
43564355
{
@@ -4542,7 +4541,7 @@
45424541
"type-specification-statements": {
45434542
"name": "meta.specification.type.fortran",
45444543
"comment": "Supported types for function and escape :: if function is used as a variable name (which is bad practice).",
4545-
"begin": "(?ix)(?=\\b(?:character|class|complex|double\\s*precision|double\\s*complex|integer|logical|real|type|dimension)\\b(?![^'\";!\\n]*(?<!\\(\\s*|::\\s*)\\bfunction\\b))",
4544+
"begin": "(?ix)(?=\\b(?:character|class|complex|double\\s*precision|double\\s*complex|integer|logical|real|type|dimension)\\b(?![^'\";!\\n:]*\\bfunction\\b))",
45464545
"end": "(?=[\\);!\\n])",
45474546
"patterns": [
45484547
{

test/resources/long_lines.f90

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
program long_lines
2+
res = (CF*(28*nf + CA*(-202 + 189*Zeta3)))/27./(one-x) + & ! this is the regular part of the plus distribution 1/(1-x)_+
3+
! now add the regular terms
4+
& (CF*(-344 + 24*Pi**2 + 974*x - 1600*CA*x + 1188*CF*x - 432*CA*HPL30*x + 1080*CF*HPL30*x + 148*nf*x - 60*Pi**2*x + 54*CA*Pi**2*x - 54*CF*Pi**2*x - 1188*x**2 + 1584*CA*x**2 - 2376*CF*x**2 - 72*nf*x**2 + 72*Pi**2*x**2 - 108*CA*Pi**2*x**2 + 108*CF*Pi**2*x**2 + 830*x**3 + 16*CA*x**3 + 1188*CF*x**3 - 432*CA*HPL30*x**3 + 1080*CF*HPL30*x**3 - 76*nf*x**3 - 60*Pi**2*x**3 + 54*CA*Pi**2*x**3 - 54*CF*Pi**2*x**3 - 272*x**4 + 24*Pi**2*x**4 + 216*(CA - CF)*HPL31*x*(1 + x**2) + 1188*CA*x*zeta3 - 1080*CF*x*zeta3 - 324*CA*x**3*zeta3 - 1080*CF*x**3*zeta3 - 36*CA*Pi**2*x*log(1 - x) + 36*CF*Pi**2*x*log(1 - x) - 108*CA*x**2*log(1 - x) + 108*CF*x**2*log(1 - x) + 108*CA*x**3*log(1 - x) - 108*CF*x**3*log(1 - x) - 36*CA*Pi**2*x**3*log(1 - x) + 36*CF*Pi**2*x**3*log(1 - x) - 252*x*log(x) + 348*CA*x*log(x) - 540*CF*x*log(x) - 60*nf*x*log(x) + 612*x**2*log(x) - 432*CA*x**2*log(x) + 1404*CF*x**2*log(x) - 744*x**3*log(x) + 996*CA*x**3*log(x) - 1728*CF*x**3*log(x) - 60*nf*x**3*log(x) + 384*x**4*log(x) - 144*log(1 - x)*log(x) + 360*x*log(1 - x)*log(x)))
5+
end program long_lines

0 commit comments

Comments
 (0)