From b5919b34429387a80f9916c9fec57fded6d1e92d Mon Sep 17 00:00:00 2001 From: Bryan Phelps Date: Fri, 26 Jun 2020 07:34:30 -0700 Subject: [PATCH 1/7] Formatting --- src/Feature/Formatting/DefaultFormatter.re | 21 +++++++ src/Feature/Formatting/DefaultFormatter.rei | 17 ++++++ src/Feature/Formatting/Feature_Formatting.re | 60 ++++++++++--------- src/Feature/Formatting/Feature_Formatting.rei | 1 + src/Store/Features.re | 2 + 5 files changed, 74 insertions(+), 27 deletions(-) create mode 100644 src/Feature/Formatting/DefaultFormatter.re create mode 100644 src/Feature/Formatting/DefaultFormatter.rei diff --git a/src/Feature/Formatting/DefaultFormatter.re b/src/Feature/Formatting/DefaultFormatter.re new file mode 100644 index 0000000000..a2258f3f62 --- /dev/null +++ b/src/Feature/Formatting/DefaultFormatter.re @@ -0,0 +1,21 @@ +open EditorCoreTypes; +open Oni_Core; + +let format = (~indentation, ~languageConfiguration, ~startLineNumber, lines) => { + let rec loop = (currentLineIdx, lines, edits) => { + switch (lines) { + | [] => edits + | [hd, ...tail] => + let edit = Vim.Edit.{ + range: Range.{ + start: { line: currentLineIdx, column: Index.zero}, + stop: { line: currentLineIdx, column: Index.zero} + }, + text: [|"abc"|] + }; + loop(Index.(currentLineIdx+1), tail, [edit, ...edits]); + }; + }; + + loop(startLineNumber, lines, []); +}; diff --git a/src/Feature/Formatting/DefaultFormatter.rei b/src/Feature/Formatting/DefaultFormatter.rei new file mode 100644 index 0000000000..7bafa0b939 --- /dev/null +++ b/src/Feature/Formatting/DefaultFormatter.rei @@ -0,0 +1,17 @@ +open EditorCoreTypes; +open Oni_Core; + +// DefaultFormatter is used as a fall-back formatter when +// a formatter is not provided by a language extension. + +// [format(~indentation, ~languageConfiguration, lines)] returns +// a set of edits to correctly indent the provided [lines], based on +// [indentation] and [languageConfiguration] settings. +let format: + ( + ~indentation: IndentationSettings.t, + ~languageConfiguration: LanguageConfiguration.t, + ~startLineNumber: Index.t, + list(string) + ) => + list(Vim.Edit.t); diff --git a/src/Feature/Formatting/Feature_Formatting.re b/src/Feature/Formatting/Feature_Formatting.re index e5ac3b20e1..989b928581 100644 --- a/src/Feature/Formatting/Feature_Formatting.re +++ b/src/Feature/Formatting/Feature_Formatting.re @@ -1,4 +1,5 @@ open Exthost; +open Oni_Core; // A format [session] describes a currently in-progress format request. type session = { @@ -99,6 +100,7 @@ module Internal = { let runFormat = ( + ~languageConfiguration, ~formatFn, ~model, ~configuration, @@ -112,33 +114,6 @@ module Internal = { let indentation = Oni_Core.Indentation.getForBuffer(~buffer=buf, configuration); - let effects = - matchingFormatters - |> List.map(formatter => - formatFn( - ~handle=formatter.handle, - ~uri=Oni_Core.Buffer.getUri(buf), - ~options= - Exthost.FormattingOptions.{ - tabSize: indentation.tabSize, - insertSpaces: - indentation.mode == Oni_Core.IndentationSettings.Spaces, - }, - extHostClient, - res => { - switch (res) { - | Ok(edits) => - EditsReceived({ - displayName: formatter.displayName, - sessionId, - edits: List.map(extHostEditToVimEdit, edits), - }) - | Error(msg) => EditRequestFailed({sessionId, msg}) - } - }) - ) - |> Isolinear.Effect.batch; - if (matchingFormatters == []) { ( model, @@ -147,6 +122,33 @@ module Internal = { ), ); } else { + let effects = + matchingFormatters + |> List.map(formatter => + formatFn( + ~handle=formatter.handle, + ~uri=Oni_Core.Buffer.getUri(buf), + ~options= + Exthost.FormattingOptions.{ + tabSize: indentation.tabSize, + insertSpaces: + indentation.mode == Oni_Core.IndentationSettings.Spaces, + }, + extHostClient, + res => { + switch (res) { + | Ok(edits) => + EditsReceived({ + displayName: formatter.displayName, + sessionId, + edits: List.map(extHostEditToVimEdit, edits), + }) + | Error(msg) => EditRequestFailed({sessionId, msg}) + } + }) + ) + |> Isolinear.Effect.batch; + (model |> startSession(~sessionId, ~buffer=buf), Effect(effects)); }; }; @@ -154,6 +156,8 @@ module Internal = { let update = ( + // TODO + ~languageConfiguration, ~configuration, ~maybeSelection, ~maybeBuffer, @@ -177,6 +181,7 @@ let update = ); Internal.runFormat( + ~languageConfiguration, ~formatFn= Service_Exthost.Effects.LanguageFeatures.provideDocumentRangeFormattingEdits( ~range, @@ -207,6 +212,7 @@ let update = ); Internal.runFormat( + ~languageConfiguration, ~formatFn=Service_Exthost.Effects.LanguageFeatures.provideDocumentFormattingEdits, ~model, ~configuration, diff --git a/src/Feature/Formatting/Feature_Formatting.rei b/src/Feature/Formatting/Feature_Formatting.rei index 016c83f8f7..6d9bb8f732 100644 --- a/src/Feature/Formatting/Feature_Formatting.rei +++ b/src/Feature/Formatting/Feature_Formatting.rei @@ -48,6 +48,7 @@ type outmsg = let update: ( + ~languageConfiguration: Oni_Core.LanguageConfiguration.t, ~configuration: Oni_Core.Configuration.t, ~maybeSelection: option(Range.t), ~maybeBuffer: option(Oni_Core.Buffer.t), diff --git a/src/Store/Features.re b/src/Store/Features.re index b1173d805d..56576b7fe5 100644 --- a/src/Store/Features.re +++ b/src/Store/Features.re @@ -47,6 +47,8 @@ let update = |> Feature_Editor.Editor.selectionOrCursorRange; let (model', eff) = Feature_Formatting.update( + // TODO: + ~languageConfiguration=LanguageConfiguration.default, ~configuration=state.configuration, ~maybeBuffer, ~maybeSelection=Some(selection), From a51b9d7b8de03806c8ad1341608d248e0e8792fc Mon Sep 17 00:00:00 2001 From: Bryan Phelps Date: Fri, 26 Jun 2020 07:58:36 -0700 Subject: [PATCH 2/7] Formatting --- src/Feature/Formatting/DefaultFormatter.re | 26 +++++++---- src/Feature/Formatting/Feature_Formatting.re | 48 ++++++++++++++++++-- 2 files changed, 62 insertions(+), 12 deletions(-) diff --git a/src/Feature/Formatting/DefaultFormatter.re b/src/Feature/Formatting/DefaultFormatter.re index a2258f3f62..a254c5217c 100644 --- a/src/Feature/Formatting/DefaultFormatter.re +++ b/src/Feature/Formatting/DefaultFormatter.re @@ -5,15 +5,23 @@ let format = (~indentation, ~languageConfiguration, ~startLineNumber, lines) => let rec loop = (currentLineIdx, lines, edits) => { switch (lines) { | [] => edits - | [hd, ...tail] => - let edit = Vim.Edit.{ - range: Range.{ - start: { line: currentLineIdx, column: Index.zero}, - stop: { line: currentLineIdx, column: Index.zero} - }, - text: [|"abc"|] - }; - loop(Index.(currentLineIdx+1), tail, [edit, ...edits]); + | [hd, ...tail] => + let edit = + Vim.Edit.{ + range: + Range.{ + start: { + line: currentLineIdx, + column: Index.zero, + }, + stop: { + line: currentLineIdx, + column: Index.zero, + }, + }, + text: [|"abc"|], + }; + loop(Index.(currentLineIdx + 1), tail, [edit, ...edits]); }; }; diff --git a/src/Feature/Formatting/Feature_Formatting.re b/src/Feature/Formatting/Feature_Formatting.re index 989b928581..99d34505cb 100644 --- a/src/Feature/Formatting/Feature_Formatting.re +++ b/src/Feature/Formatting/Feature_Formatting.re @@ -1,3 +1,4 @@ +open EditorCoreTypes; open Exthost; open Oni_Core; @@ -98,6 +99,43 @@ module Internal = { text: textToArray(edit.text), }; + let fallBackToDefaultFormatter = + ( + ~indentation, + ~languageConfiguration, + ~buffer, + // TODO: Hook up range + _range, + ) => { + let lines = buffer |> Oni_Core.Buffer.getLines |> Array.to_list; + + let edits = + DefaultFormatter.format( + ~indentation, + ~languageConfiguration, + // TODO + ~startLineNumber=Index.zero, + lines, + ); + + let displayName = "Default"; + if (edits == []) { + FormattingApplied({displayName, editCount: 0}); + } else { + let effect = + Service_Vim.Effects.applyEdits( + ~bufferId=buffer |> Oni_Core.Buffer.getId, + ~version=buffer |> Oni_Core.Buffer.getVersion, + ~edits, + fun + | Ok () => + EditCompleted({editCount: List.length(edits), displayName}) + | Error(msg) => EditRequestFailed({sessionId: 0, msg}), + ); + Effect(effect); + }; + }; + let runFormat = ( ~languageConfiguration, @@ -117,8 +155,12 @@ module Internal = { if (matchingFormatters == []) { ( model, - FormatError( - Printf.sprintf("No format providers available for %s", filetype), + fallBackToDefaultFormatter( + ~indentation, + ~languageConfiguration, + ~buffer=buf, + // TODO: Range + (), ), ); } else { @@ -155,8 +197,8 @@ module Internal = { }; let update = + // TODO ( - // TODO ~languageConfiguration, ~configuration, ~maybeSelection, From 3f74fc931422a562825a55bc732de9ccab300b56 Mon Sep 17 00:00:00 2001 From: Bryan Phelps Date: Fri, 26 Jun 2020 08:38:43 -0700 Subject: [PATCH 3/7] Add default format strategy --- src/Core/Indentation.re | 15 +++++ src/Core/IndentationGuesser.re | 20 +------ src/Feature/Formatting/DefaultFormatter.re | 60 +++++++++++++------- src/Feature/Formatting/DefaultFormatter.rei | 2 +- src/Feature/Formatting/Feature_Formatting.re | 2 +- 5 files changed, 58 insertions(+), 41 deletions(-) diff --git a/src/Core/Indentation.re b/src/Core/Indentation.re index cfbb685eae..6d34c23ef8 100644 --- a/src/Core/Indentation.re +++ b/src/Core/Indentation.re @@ -4,6 +4,21 @@ * Helpers for dealing with indentation level */ +let getLeadingWhitespace = (s: string) => { + let rec loop = (i, spaces, tabs) => + if (i >= String.length(s)) { + (spaces, tabs, false); + } else { + switch (s.[i]) { + | ' ' => loop(i + 1, spaces + 1, tabs) + | '\t' => loop(i + 1, spaces, tabs + 1) + | _ => (spaces, tabs, true) + }; + }; + + loop(0, 0, 0); +}; + let getLevel = (settings: IndentationSettings.t, text: string) => { let tabSize = settings.tabSize; diff --git a/src/Core/IndentationGuesser.re b/src/Core/IndentationGuesser.re index b2a6e5045c..056c1f6bfc 100644 --- a/src/Core/IndentationGuesser.re +++ b/src/Core/IndentationGuesser.re @@ -8,21 +8,6 @@ module Constants = { let minSpaces = 2; }; -let getLeadingWhitespace = (s: string) => { - let rec loop = (i, spaces, tabs) => - if (i >= String.length(s)) { - (spaces, tabs, false); - } else { - switch (s.[i]) { - | ' ' => loop(i + 1, spaces + 1, tabs) - | '\t' => loop(i + 1, spaces, tabs + 1) - | _ => (spaces, tabs, true) - }; - }; - - loop(0, 0, 0); -}; - type t = { mode: IndentationSettings.mode, size: int, @@ -62,7 +47,8 @@ let guessIndentation = let line = getLine(i); let prevLine = i == 0 ? "" : getLine(i - 1); - let (spaceCount, tabCount, foundChar) = getLeadingWhitespace(line); + let (spaceCount, tabCount, foundChar) = + Indentation.getLeadingWhitespace(line); /* Only consider lines with non-whitespace */ if (foundChar) { @@ -75,7 +61,7 @@ let guessIndentation = }; let (prevSpaceCount, _, prevFoundChar) = - getLeadingWhitespace(prevLine); + Indentation.getLeadingWhitespace(prevLine); if (prevFoundChar) { let diff = abs(prevSpaceCount - spaceCount); if (diff >= Constants.minSpaces) { diff --git a/src/Feature/Formatting/DefaultFormatter.re b/src/Feature/Formatting/DefaultFormatter.re index a254c5217c..3a32f0683c 100644 --- a/src/Feature/Formatting/DefaultFormatter.re +++ b/src/Feature/Formatting/DefaultFormatter.re @@ -2,28 +2,44 @@ open EditorCoreTypes; open Oni_Core; let format = (~indentation, ~languageConfiguration, ~startLineNumber, lines) => { - let rec loop = (currentLineIdx, lines, edits) => { - switch (lines) { - | [] => edits - | [hd, ...tail] => - let edit = - Vim.Edit.{ - range: - Range.{ - start: { - line: currentLineIdx, - column: Index.zero, - }, - stop: { - line: currentLineIdx, - column: Index.zero, - }, - }, - text: [|"abc"|], - }; - loop(Index.(currentLineIdx + 1), tail, [edit, ...edits]); + let len: int = Array.length(lines); + let lenIdx = + Index.toZeroBased(startLineNumber) + len - 1 |> Index.fromZeroBased; + let out = Array.copy(lines); + + if (len == 0) { + []; + } else { + let previousLine = ref(lines[0]); + let beforePreviousLine = ref(None); + let _currentIndentationlevel = + ref(Indentation.getLevel(indentation, lines[0])); + + for (idx in 1 to len - 1) { + let line = lines[idx]; + // TODO: Actually process indentation... + out[idx] = "abc " ++ lines[idx]; + + beforePreviousLine := Some(previousLine^); + previousLine := line; }; - }; - loop(startLineNumber, lines, []); + let edit = + Vim.Edit.{ + range: + Range.{ + start: { + line: startLineNumber, + column: Index.zero, + }, + stop: { + line: lenIdx, + column: Index.fromZeroBased(Zed_utf8.length(lines[len - 1])), + }, + }, + text: out, + }; + + [edit]; + }; }; diff --git a/src/Feature/Formatting/DefaultFormatter.rei b/src/Feature/Formatting/DefaultFormatter.rei index 7bafa0b939..3479c1f609 100644 --- a/src/Feature/Formatting/DefaultFormatter.rei +++ b/src/Feature/Formatting/DefaultFormatter.rei @@ -12,6 +12,6 @@ let format: ~indentation: IndentationSettings.t, ~languageConfiguration: LanguageConfiguration.t, ~startLineNumber: Index.t, - list(string) + array(string) ) => list(Vim.Edit.t); diff --git a/src/Feature/Formatting/Feature_Formatting.re b/src/Feature/Formatting/Feature_Formatting.re index 99d34505cb..a2b314d7c8 100644 --- a/src/Feature/Formatting/Feature_Formatting.re +++ b/src/Feature/Formatting/Feature_Formatting.re @@ -107,7 +107,7 @@ module Internal = { // TODO: Hook up range _range, ) => { - let lines = buffer |> Oni_Core.Buffer.getLines |> Array.to_list; + let lines = buffer |> Oni_Core.Buffer.getLines; let edits = DefaultFormatter.format( From 8666a8a6b478a5959b91b3e8cf9bb1e5bb62b469 Mon Sep 17 00:00:00 2001 From: Bryan Phelps Date: Sat, 27 Jun 2020 13:33:46 -0700 Subject: [PATCH 4/7] Process indentation ranges --- src/Core/Indentation.re | 18 +++ src/Core/LanguageConfiguration.re | 53 ++++---- src/Core/LanguageConfiguration.rei | 5 + src/Core/Utility/StringEx.re | 19 +-- src/Feature/Formatting/DefaultFormatter.re | 102 +++++++++----- src/Feature/Formatting/Feature_Formatting.re | 128 +++++++++++++----- src/Feature/Formatting/Feature_Formatting.rei | 6 +- src/Store/VimStoreConnector.re | 6 +- 8 files changed, 233 insertions(+), 104 deletions(-) diff --git a/src/Core/Indentation.re b/src/Core/Indentation.re index 6d34c23ef8..82f2bbc997 100644 --- a/src/Core/Indentation.re +++ b/src/Core/Indentation.re @@ -4,6 +4,8 @@ * Helpers for dealing with indentation level */ +open Utility; + let getLeadingWhitespace = (s: string) => { let rec loop = (i, spaces, tabs) => if (i >= String.length(s)) { @@ -53,6 +55,22 @@ let getLevel = (settings: IndentationSettings.t, text: string) => { allWhitespace^ ? 0 : indentLevel^; }; +let applyLevel = + (~indentation: IndentationSettings.t, ~level: int, str: string) => { + str + |> StringEx.findNonWhitespace + |> Option.map(idx => { + let desiredWhitespace = + switch (indentation.mode) { + | Tabs => String.make(level, '\t') + | Spaces => String.make(level * indentation.size, ' ') + }; + + desiredWhitespace ++ String.sub(str, idx, String.length(str) - idx); + }) + |> Option.value(~default=str); +}; + let getForBuffer = (~buffer, configuration: Configuration.t) => { let bufferIndentation = Buffer.getIndentation(buffer); switch (bufferIndentation) { diff --git a/src/Core/LanguageConfiguration.re b/src/Core/LanguageConfiguration.re index 9792d4ab4e..a87c73bfe7 100644 --- a/src/Core/LanguageConfiguration.re +++ b/src/Core/LanguageConfiguration.re @@ -226,36 +226,37 @@ let toVimAutoClosingPairs = (syntaxScope: SyntaxScope.t, configuration: t) => { ); }; -let toAutoIndent = +let shouldIncreaseIndent = ( - {increaseIndentPattern, decreaseIndentPattern, brackets, _}, ~previousLine as str, ~beforePreviousLine as _, + {increaseIndentPattern, brackets, _}, ) => { - let increase = - increaseIndentPattern - |> Option.map(regex => OnigRegExp.test(str, regex)) - // If no indentation pattern, fall-back to bracket pair - |> OptionEx.or_lazy(() => - Some( - List.exists( - bracket => BracketPair.endsWithOpenPair(bracket, str), - brackets, - ), - ) + increaseIndentPattern + |> Option.map(regex => OnigRegExp.test(str, regex)) + // If no indentation pattern, fall-back to bracket pair + |> OptionEx.or_lazy(() => + Some( + List.exists( + bracket => BracketPair.endsWithOpenPair(bracket, str), + brackets, + ), ) - |> Option.value(~default=false); - - let decrease = - decreaseIndentPattern - |> Option.map(regex => OnigRegExp.test(str, regex)) - |> Option.value(~default=false); - - if (increase) { - Vim.AutoIndent.IncreaseIndent; - } else if (decrease) { - Vim.AutoIndent.DecreaseIndent; - } else { - Vim.AutoIndent.KeepIndent; + ) + |> Option.value(~default=false); +}; + +let shouldDecreaseIndent = (~line, {decreaseIndentPattern, _}) => { + decreaseIndentPattern + |> Option.map(regex => OnigRegExp.test(line, regex)) + |> Option.value(~default=false); +}; + +let toAutoIndent = (languageConfig, ~previousLine, ~beforePreviousLine) => { + let increase = + shouldIncreaseIndent(~previousLine, ~beforePreviousLine, languageConfig); + + if (increase) {Vim.AutoIndent.IncreaseIndent} else { + Vim.AutoIndent.KeepIndent }; }; diff --git a/src/Core/LanguageConfiguration.rei b/src/Core/LanguageConfiguration.rei index 213f2f8566..10663a0869 100644 --- a/src/Core/LanguageConfiguration.rei +++ b/src/Core/LanguageConfiguration.rei @@ -40,6 +40,11 @@ type t = { let default: t; +let shouldIncreaseIndent: + (~previousLine: string, ~beforePreviousLine: option(string), t) => bool; + +let shouldDecreaseIndent: (~line: string, t) => bool; + let decode: Json.decoder(t); let toVimAutoClosingPairs: (SyntaxScope.t, t) => Vim.AutoClosingPairs.t; diff --git a/src/Core/Utility/StringEx.re b/src/Core/Utility/StringEx.re index a0f5c5fff6..1923fc8664 100644 --- a/src/Core/Utility/StringEx.re +++ b/src/Core/Utility/StringEx.re @@ -112,16 +112,19 @@ let trimRight = str => { aux(length - 1); }; -let indentation = str => { - let rec loop = i => - if (i >= String.length(str)) { - i; - } else if (isSpace(str.[i])) { - loop(i + 1); +let findNonWhitespace = str => { + let len = String.length(str); + let rec loop = idx => + if (idx >= len) { + None; } else { - i; + let char = str.[idx]; + if (char != '\t' && char != ' ') { + Some(idx); + } else { + loop(idx + 1); + }; }; - loop(0); }; diff --git a/src/Feature/Formatting/DefaultFormatter.re b/src/Feature/Formatting/DefaultFormatter.re index 3a32f0683c..3a43547689 100644 --- a/src/Feature/Formatting/DefaultFormatter.re +++ b/src/Feature/Formatting/DefaultFormatter.re @@ -1,45 +1,79 @@ open EditorCoreTypes; open Oni_Core; +module Internal = { + let doFormat = (~indentation, ~languageConfiguration, lines) => { + let len: int = Array.length(lines); + let out = Array.copy(lines); + + if (len > 0) { + let previousLine = ref(lines[0]); + let beforePreviousLine = ref(None); + let currentIndentationlevel = + ref(Indentation.getLevel(indentation, lines[0])); + + for (idx in 1 to len - 1) { + let line = lines[idx]; + + let increaseIndentAmount = + LanguageConfiguration.shouldIncreaseIndent( + ~previousLine=previousLine^, + ~beforePreviousLine=beforePreviousLine^, + languageConfiguration, + ) + ? 1 : 0; + + let decreaseIndentAmount = + LanguageConfiguration.shouldDecreaseIndent( + ~line, + languageConfiguration, + ) + ? (-1) : 0; + + let newIndentLevel = + // TODO: Fix this + currentIndentationlevel^ + + increaseIndentAmount + + decreaseIndentAmount + + 1; + + out[idx] = + Indentation.applyLevel( + ~indentation, + ~level=newIndentLevel, + lines[idx], + ); + + currentIndentationlevel := newIndentLevel; + beforePreviousLine := Some(previousLine^); + previousLine := line; + }; + }; + out; + }; +}; + let format = (~indentation, ~languageConfiguration, ~startLineNumber, lines) => { let len: int = Array.length(lines); let lenIdx = Index.toZeroBased(startLineNumber) + len - 1 |> Index.fromZeroBased; - let out = Array.copy(lines); - - if (len == 0) { - []; - } else { - let previousLine = ref(lines[0]); - let beforePreviousLine = ref(None); - let _currentIndentationlevel = - ref(Indentation.getLevel(indentation, lines[0])); - - for (idx in 1 to len - 1) { - let line = lines[idx]; - // TODO: Actually process indentation... - out[idx] = "abc " ++ lines[idx]; - - beforePreviousLine := Some(previousLine^); - previousLine := line; - }; + let out = Internal.doFormat(~indentation, ~languageConfiguration, lines); - let edit = - Vim.Edit.{ - range: - Range.{ - start: { - line: startLineNumber, - column: Index.zero, - }, - stop: { - line: lenIdx, - column: Index.fromZeroBased(Zed_utf8.length(lines[len - 1])), - }, + let edit = + Vim.Edit.{ + range: + Range.{ + start: { + line: startLineNumber, + column: Index.zero, }, - text: out, - }; + stop: { + line: lenIdx, + column: Index.fromZeroBased(Zed_utf8.length(lines[len - 1])), + }, + }, + text: out, + }; - [edit]; - }; + [edit]; }; diff --git a/src/Feature/Formatting/Feature_Formatting.re b/src/Feature/Formatting/Feature_Formatting.re index a2b314d7c8..b8612c355d 100644 --- a/src/Feature/Formatting/Feature_Formatting.re +++ b/src/Feature/Formatting/Feature_Formatting.re @@ -32,11 +32,15 @@ let initial = { [@deriving show] type command = | FormatDocument - | FormatRange; + | FormatSelection; [@deriving show] type msg = | Command(command) + | FormatRange({ + startLine: Index.t, + endLine: Index.t, + }) | DocumentFormatterAvailable({ handle: int, selector: Exthost.DocumentSelector.t, @@ -100,39 +104,45 @@ module Internal = { }; let fallBackToDefaultFormatter = - ( - ~indentation, - ~languageConfiguration, - ~buffer, - // TODO: Hook up range - _range, - ) => { + (~indentation, ~languageConfiguration, ~buffer, range: Range.t) => { let lines = buffer |> Oni_Core.Buffer.getLines; - let edits = - DefaultFormatter.format( - ~indentation, - ~languageConfiguration, - // TODO - ~startLineNumber=Index.zero, - lines, - ); + let startLine = Index.toZeroBased(range.start.line); + let stopLine = Index.toZeroBased(range.stop.line); - let displayName = "Default"; - if (edits == []) { - FormattingApplied({displayName, editCount: 0}); - } else { - let effect = - Service_Vim.Effects.applyEdits( - ~bufferId=buffer |> Oni_Core.Buffer.getId, - ~version=buffer |> Oni_Core.Buffer.getVersion, - ~edits, - fun - | Ok () => - EditCompleted({editCount: List.length(edits), displayName}) - | Error(msg) => EditRequestFailed({sessionId: 0, msg}), + if (startLine >= 0 + && startLine < Array.length(lines) + && stopLine < Array.length(lines)) { + let lines = Array.sub(lines, startLine, stopLine - startLine + 1); + + lines |> Array.iter(prerr_endline); + + let edits = + DefaultFormatter.format( + ~indentation, + ~languageConfiguration, + ~startLineNumber=range.start.line, + lines, ); - Effect(effect); + + let displayName = "Default"; + if (edits == []) { + FormattingApplied({displayName, editCount: 0}); + } else { + let effect = + Service_Vim.Effects.applyEdits( + ~bufferId=buffer |> Oni_Core.Buffer.getId, + ~version=buffer |> Oni_Core.Buffer.getVersion, + ~edits, + fun + | Ok () => + EditCompleted({editCount: List.length(edits), displayName}) + | Error(msg) => EditRequestFailed({sessionId: 0, msg}), + ); + Effect(effect); + }; + } else { + FormatError("Invalid range specified"); }; }; @@ -146,6 +156,7 @@ module Internal = { ~buf, ~filetype, ~extHostClient, + ~range, ) => { let sessionId = model.nextSessionId; @@ -159,8 +170,7 @@ module Internal = { ~indentation, ~languageConfiguration, ~buffer=buf, - // TODO: Range - (), + range, ), ); } else { @@ -208,7 +218,48 @@ let update = msg, ) => { switch (msg) { - | Command(FormatRange) => + | FormatRange({startLine, endLine}) => + switch (maybeBuffer) { + | Some(buf) => + let range = + Range.{ + start: { + line: startLine, + column: Index.zero, + }, + stop: { + line: endLine, + column: Index.zero, + }, + }; + let filetype = + buf + |> Oni_Core.Buffer.getFileType + |> Option.value(~default="plaintext"); + + let matchingFormatters = + model.availableRangeFormatters + |> List.filter(({selector, _}) => + DocumentSelector.matches(~filetype, selector) + ); + + Internal.runFormat( + ~languageConfiguration, + ~formatFn= + Service_Exthost.Effects.LanguageFeatures.provideDocumentRangeFormattingEdits( + ~range, + ), + ~model, + ~configuration, + ~matchingFormatters, + ~buf, + ~filetype, + ~extHostClient, + ~range, + ); + | None => (model, FormatError("No range selected")) + } + | Command(FormatSelection) => switch (maybeBuffer, maybeSelection) { | (Some(buf), Some(range)) => let filetype = @@ -234,6 +285,7 @@ let update = ~buf, ~filetype, ~extHostClient, + ~range, ); | _ => (model, FormatError("No range selected.")) } @@ -262,6 +314,16 @@ let update = ~buf, ~filetype, ~extHostClient, + ~range= + Range.{ + start: Location.{line: Index.zero, column: Index.zero}, + stop: + Location.{ + line: + Oni_Core.Buffer.getNumberOfLines(buf) |> Index.fromZeroBased, + column: Index.zero, + }, + }, ); } | DocumentFormatterAvailable({handle, selector, displayName}) => ( diff --git a/src/Feature/Formatting/Feature_Formatting.rei b/src/Feature/Formatting/Feature_Formatting.rei index 6d9bb8f732..381f93cd5d 100644 --- a/src/Feature/Formatting/Feature_Formatting.rei +++ b/src/Feature/Formatting/Feature_Formatting.rei @@ -8,11 +8,15 @@ let initial: model; [@deriving show] type command = | FormatDocument - | FormatRange; + | FormatSelection; [@deriving show] type msg = | Command(command) + | FormatRange({ + startLine: Index.t, + endLine: Index.t, + }) | DocumentFormatterAvailable({ handle: int, selector: Exthost.DocumentSelector.t, diff --git a/src/Store/VimStoreConnector.re b/src/Store/VimStoreConnector.re index b6d29c95da..fa9ae9e570 100644 --- a/src/Store/VimStoreConnector.re +++ b/src/Store/VimStoreConnector.re @@ -125,9 +125,11 @@ let start = dispatch( Actions.Formatting(Feature_Formatting.Command(FormatDocument)), ) - | Format(Range(_)) => + | Format(Range({startLine, endLine})) => dispatch( - Actions.Formatting(Feature_Formatting.Command(FormatRange)), + Actions.Formatting( + Feature_Formatting.FormatRange({startLine, endLine}), + ), ), ); From 73719c5f09ed95fe42ed2b9008b49cd125ea5287 Mon Sep 17 00:00:00 2001 From: Bryan Phelps Date: Sat, 27 Jun 2020 14:48:19 -0700 Subject: [PATCH 5/7] Additional cases --- src/Core/LanguageConfiguration.re | 38 +++++- src/Core/Utility/StringEx.re | 7 + src/Feature/Formatting/DefaultFormatter.re | 131 ++++++++++++++----- src/Feature/Formatting/Feature_Formatting.re | 9 +- src/Feature/Formatting/dune | 3 +- src/Store/VimStoreConnector.re | 2 +- 6 files changed, 148 insertions(+), 42 deletions(-) diff --git a/src/Core/LanguageConfiguration.re b/src/Core/LanguageConfiguration.re index a87c73bfe7..37dd83a915 100644 --- a/src/Core/LanguageConfiguration.re +++ b/src/Core/LanguageConfiguration.re @@ -92,6 +92,34 @@ module BracketPair = { let endsWithOpenPair = ({openPair, _}, str) => { StringEx.endsWith(~postfix=openPair, str); }; + + let isJustClosingPair = ({closePair, _}, str) => { + let len = String.length(str); + + let rec loop = (foundPair, idx) => + if (idx >= len) { + foundPair; + } else if (foundPair) { + false; + // We found the closing pair... but there's other stuff after + } else { + let c = str.[idx]; + + if (c == ' ' || c == '\t') { + loop(foundPair, idx + 1); + } else if (c == closePair.[0]) { + loop(true, idx + 1); + } else { + false; + }; + }; + + if (String.length(closePair) == 1) { + loop(false, 0); + } else { + false; + }; + }; }; let defaultBrackets: list(BracketPair.t) = @@ -246,9 +274,17 @@ let shouldIncreaseIndent = |> Option.value(~default=false); }; -let shouldDecreaseIndent = (~line, {decreaseIndentPattern, _}) => { +let shouldDecreaseIndent = (~line, {decreaseIndentPattern, brackets,_}) => { decreaseIndentPattern |> Option.map(regex => OnigRegExp.test(line, regex)) + |> OptionEx.or_lazy(() => { + Some( + List.exists( + bracket => BracketPair.isJustClosingPair(bracket, line), + brackets, + ), + ) + }) |> Option.value(~default=false); }; diff --git a/src/Core/Utility/StringEx.re b/src/Core/Utility/StringEx.re index 1923fc8664..a241526538 100644 --- a/src/Core/Utility/StringEx.re +++ b/src/Core/Utility/StringEx.re @@ -128,6 +128,13 @@ let findNonWhitespace = str => { loop(0); }; +let isOnlyWhitespace = str => { + switch (findNonWhitespace(str)) { + | None => true + | Some(_) => false + } +}; + let extractSnippet = (~maxLength, ~charStart, ~charEnd, text) => { let originalLength = String.length(text); diff --git a/src/Feature/Formatting/DefaultFormatter.re b/src/Feature/Formatting/DefaultFormatter.re index 3a43547689..19cbb80757 100644 --- a/src/Feature/Formatting/DefaultFormatter.re +++ b/src/Feature/Formatting/DefaultFormatter.re @@ -1,5 +1,6 @@ open EditorCoreTypes; open Oni_Core; +open Oni_Core.Utility; module Internal = { let doFormat = (~indentation, ~languageConfiguration, lines) => { @@ -15,42 +16,108 @@ module Internal = { for (idx in 1 to len - 1) { let line = lines[idx]; - let increaseIndentAmount = - LanguageConfiguration.shouldIncreaseIndent( - ~previousLine=previousLine^, - ~beforePreviousLine=beforePreviousLine^, - languageConfiguration, - ) - ? 1 : 0; - - let decreaseIndentAmount = - LanguageConfiguration.shouldDecreaseIndent( - ~line, - languageConfiguration, - ) - ? (-1) : 0; - - let newIndentLevel = - // TODO: Fix this - currentIndentationlevel^ - + increaseIndentAmount - + decreaseIndentAmount - + 1; - - out[idx] = - Indentation.applyLevel( - ~indentation, - ~level=newIndentLevel, - lines[idx], - ); - - currentIndentationlevel := newIndentLevel; - beforePreviousLine := Some(previousLine^); - previousLine := line; + if (StringEx.isOnlyWhitespace(line)) { + out[idx] = ""; + } else { + let increaseIndentAmount = + LanguageConfiguration.shouldIncreaseIndent( + ~previousLine=previousLine^, + ~beforePreviousLine=beforePreviousLine^, + languageConfiguration, + ) + ? 1 : 0; + + let decreaseIndentAmount = + LanguageConfiguration.shouldDecreaseIndent( + ~line, + languageConfiguration, + ) + ? (-1) : 0; + + let newIndentLevel = + currentIndentationlevel^ + + increaseIndentAmount + + decreaseIndentAmount; + + out[idx] = + Indentation.applyLevel( + ~indentation, + ~level=newIndentLevel, + lines[idx], + ); + + currentIndentationlevel := newIndentLevel; + beforePreviousLine := Some(previousLine^); + previousLine := line; + } }; }; out; }; + + + let%test_module "format" = + (module + { + let buffer = lines => lines |> Array.of_list; + + let indent2Spaces = IndentationSettings.{ + mode: Spaces, + size: 2, + tabSize: 2, + }; + + let indentTabs = IndentationSettings.{ + mode: Tabs, + size: 1, + tabSize: 2, + }; + + let languageConfiguration = LanguageConfiguration.default; +// + let%test "empty array" = { + buffer([]) + |> doFormat( + ~indentation=indent2Spaces, + ~languageConfiguration) == [||]; + }; + + let%test "no indent" = { + buffer(["abc"]) + |> doFormat( + ~indentation=indent2Spaces, + ~languageConfiguration) == [|"abc"|]; + }; + + let%test "simple indent" = { + buffer(["{", "abc"]) + |> doFormat( + ~indentation=indent2Spaces, + ~languageConfiguration) == [|"{", " abc"|]; + }; + + let%test "increase / decrease indent" = { + buffer(["{", "abc", "}"]) + |> doFormat( + ~indentation=indent2Spaces, + ~languageConfiguration) == [|"{", " abc", "}"|]; + }; + + let%test "extraneous whitespace is ignored" = { + buffer(["{", " ", "abc", "}"]) + |> doFormat( + ~indentation=indent2Spaces, + ~languageConfiguration) == [|"{", "", " abc", "}"|]; + }; + + let%test "increase / decrease indent (tabs)" = { + buffer(["{", "abc", "}"]) + |> doFormat( + ~indentation=indentTabs, + ~languageConfiguration) == [|"{", "\tabc", "}"|]; + }; + }); + }; let format = (~indentation, ~languageConfiguration, ~startLineNumber, lines) => { diff --git a/src/Feature/Formatting/Feature_Formatting.re b/src/Feature/Formatting/Feature_Formatting.re index b8612c355d..ab2a522264 100644 --- a/src/Feature/Formatting/Feature_Formatting.re +++ b/src/Feature/Formatting/Feature_Formatting.re @@ -154,7 +154,6 @@ module Internal = { ~configuration, ~matchingFormatters, ~buf, - ~filetype, ~extHostClient, ~range, ) => { @@ -207,7 +206,6 @@ module Internal = { }; let update = - // TODO ( ~languageConfiguration, ~configuration, @@ -253,7 +251,6 @@ let update = ~configuration, ~matchingFormatters, ~buf, - ~filetype, ~extHostClient, ~range, ); @@ -283,7 +280,6 @@ let update = ~configuration, ~matchingFormatters, ~buf, - ~filetype, ~extHostClient, ~range, ); @@ -312,13 +308,12 @@ let update = ~configuration, ~matchingFormatters, ~buf, - ~filetype, ~extHostClient, ~range= Range.{ - start: Location.{line: Index.zero, column: Index.zero}, + start: {line: Index.zero, column: Index.zero}, stop: - Location.{ + { line: Oni_Core.Buffer.getNumberOfLines(buf) |> Index.fromZeroBased, column: Index.zero, diff --git a/src/Feature/Formatting/dune b/src/Feature/Formatting/dune index 94c8c872fc..133f371ba2 100644 --- a/src/Feature/Formatting/dune +++ b/src/Feature/Formatting/dune @@ -1,6 +1,7 @@ (library (name Feature_Formatting) (public_name Oni2.feature.formatting) + (inline_tests) (libraries Oni2.core Oni2.components @@ -11,4 +12,4 @@ Revery isolinear ) - (preprocess (pps ppx_let ppx_deriving.show brisk-reconciler.ppx))) + (preprocess (pps ppx_let ppx_deriving.show brisk-reconciler.ppx ppx_inline_test))) diff --git a/src/Store/VimStoreConnector.re b/src/Store/VimStoreConnector.re index fa9ae9e570..5e456ecf30 100644 --- a/src/Store/VimStoreConnector.re +++ b/src/Store/VimStoreConnector.re @@ -125,7 +125,7 @@ let start = dispatch( Actions.Formatting(Feature_Formatting.Command(FormatDocument)), ) - | Format(Range({startLine, endLine})) => + | Format(Range({startLine, endLine, _})) => dispatch( Actions.Formatting( Feature_Formatting.FormatRange({startLine, endLine}), From b72d8e30df5fecdc5d5bb8781dac0605d36d2fa7 Mon Sep 17 00:00:00 2001 From: Bryan Phelps Date: Sat, 27 Jun 2020 15:21:53 -0700 Subject: [PATCH 6/7] Hook up language configuration --- src/Core/LanguageConfiguration.re | 6 +- src/Core/Utility/StringEx.re | 2 +- src/Feature/Formatting/DefaultFormatter.re | 144 ++++++++++--------- src/Feature/Formatting/Feature_Formatting.re | 16 ++- src/Store/Features.re | 15 +- 5 files changed, 104 insertions(+), 79 deletions(-) diff --git a/src/Core/LanguageConfiguration.re b/src/Core/LanguageConfiguration.re index 37dd83a915..6645b4163c 100644 --- a/src/Core/LanguageConfiguration.re +++ b/src/Core/LanguageConfiguration.re @@ -92,7 +92,7 @@ module BracketPair = { let endsWithOpenPair = ({openPair, _}, str) => { StringEx.endsWith(~postfix=openPair, str); }; - + let isJustClosingPair = ({closePair, _}, str) => { let len = String.length(str); @@ -274,7 +274,7 @@ let shouldIncreaseIndent = |> Option.value(~default=false); }; -let shouldDecreaseIndent = (~line, {decreaseIndentPattern, brackets,_}) => { +let shouldDecreaseIndent = (~line, {decreaseIndentPattern, brackets, _}) => { decreaseIndentPattern |> Option.map(regex => OnigRegExp.test(line, regex)) |> OptionEx.or_lazy(() => { @@ -284,7 +284,7 @@ let shouldDecreaseIndent = (~line, {decreaseIndentPattern, brackets,_}) => { brackets, ), ) - }) + }) |> Option.value(~default=false); }; diff --git a/src/Core/Utility/StringEx.re b/src/Core/Utility/StringEx.re index a241526538..c0d636fdd6 100644 --- a/src/Core/Utility/StringEx.re +++ b/src/Core/Utility/StringEx.re @@ -132,7 +132,7 @@ let isOnlyWhitespace = str => { switch (findNonWhitespace(str)) { | None => true | Some(_) => false - } + }; }; let extractSnippet = (~maxLength, ~charStart, ~charEnd, text) => { diff --git a/src/Feature/Formatting/DefaultFormatter.re b/src/Feature/Formatting/DefaultFormatter.re index 19cbb80757..1bda016f2b 100644 --- a/src/Feature/Formatting/DefaultFormatter.re +++ b/src/Feature/Formatting/DefaultFormatter.re @@ -10,114 +10,126 @@ module Internal = { if (len > 0) { let previousLine = ref(lines[0]); let beforePreviousLine = ref(None); - let currentIndentationlevel = - ref(Indentation.getLevel(indentation, lines[0])); + let currentIndentationLevel = ref(None); - for (idx in 1 to len - 1) { + for (idx in 0 to len - 1) { let line = lines[idx]; if (StringEx.isOnlyWhitespace(line)) { out[idx] = ""; } else { - let increaseIndentAmount = - LanguageConfiguration.shouldIncreaseIndent( - ~previousLine=previousLine^, - ~beforePreviousLine=beforePreviousLine^, - languageConfiguration, - ) - ? 1 : 0; - - let decreaseIndentAmount = - LanguageConfiguration.shouldDecreaseIndent( - ~line, - languageConfiguration, - ) - ? (-1) : 0; - - let newIndentLevel = - currentIndentationlevel^ - + increaseIndentAmount - + decreaseIndentAmount; + let indentLevel = + switch (currentIndentationLevel^) { + | None => Indentation.getLevel(indentation, line) + | Some(indent) => + let increaseIndentAmount = + LanguageConfiguration.shouldIncreaseIndent( + ~previousLine=previousLine^, + ~beforePreviousLine=beforePreviousLine^, + languageConfiguration, + ) + ? 1 : 0; + + let decreaseIndentAmount = + LanguageConfiguration.shouldDecreaseIndent( + ~line, + languageConfiguration, + ) + ? (-1) : 0; + + indent + increaseIndentAmount + decreaseIndentAmount; + }; out[idx] = Indentation.applyLevel( ~indentation, - ~level=newIndentLevel, + ~level=indentLevel, lines[idx], ); - currentIndentationlevel := newIndentLevel; + currentIndentationLevel := Some(indentLevel); beforePreviousLine := Some(previousLine^); previousLine := line; - } + }; }; }; out; }; - let%test_module "format" = (module { let buffer = lines => lines |> Array.of_list; - let indent2Spaces = IndentationSettings.{ - mode: Spaces, - size: 2, - tabSize: 2, - }; + let indent2Spaces = + IndentationSettings.{mode: Spaces, size: 2, tabSize: 2}; + let indent3Spaces = + IndentationSettings.{mode: Spaces, size: 3, tabSize: 3}; - let indentTabs = IndentationSettings.{ - mode: Tabs, - size: 1, - tabSize: 2, - }; + let indentTabs = IndentationSettings.{mode: Tabs, size: 1, tabSize: 2}; let languageConfiguration = LanguageConfiguration.default; -// + let%test "empty array" = { - buffer([]) - |> doFormat( - ~indentation=indent2Spaces, - ~languageConfiguration) == [||]; + buffer([]) + |> doFormat(~indentation=indent2Spaces, ~languageConfiguration) + == [||]; }; - + let%test "no indent" = { - buffer(["abc"]) - |> doFormat( - ~indentation=indent2Spaces, - ~languageConfiguration) == [|"abc"|]; + buffer(["abc"]) + |> doFormat(~indentation=indent2Spaces, ~languageConfiguration) + == [|"abc"|]; }; - + let%test "simple indent" = { - buffer(["{", "abc"]) - |> doFormat( - ~indentation=indent2Spaces, - ~languageConfiguration) == [|"{", " abc"|]; + buffer(["{", "abc"]) + |> doFormat(~indentation=indent2Spaces, ~languageConfiguration) + == [|"{", " abc"|]; }; let%test "increase / decrease indent" = { - buffer(["{", "abc", "}"]) - |> doFormat( - ~indentation=indent2Spaces, - ~languageConfiguration) == [|"{", " abc", "}"|]; + buffer(["{", "abc", "}"]) + |> doFormat(~indentation=indent2Spaces, ~languageConfiguration) + == [|"{", " abc", "}"|]; + }; + + let%test "2-spaces replaced with 3-spaces" = { + buffer(["{", " abc", "}"]) + |> doFormat(~indentation=indent3Spaces, ~languageConfiguration) + == [|"{", " abc", "}"|]; + }; + + let%test "spaces replaced with tabs" = { + buffer(["{", " abc", "}"]) + |> doFormat(~indentation=indentTabs, ~languageConfiguration) + == [|"{", "\tabc", "}"|]; + }; + + let%test "tabs replaced with spaces" = { + buffer(["{", "\tabc", "}"]) + |> doFormat(~indentation=indent2Spaces, ~languageConfiguration) + == [|"{", " abc", "}"|]; + }; + + let%test "initial whitespace is ignored" = { + buffer([" ", "{", "abc", "}"]) + |> doFormat(~indentation=indent2Spaces, ~languageConfiguration) + == [|"", "{", " abc", "}"|]; }; - + let%test "extraneous whitespace is ignored" = { - buffer(["{", " ", "abc", "}"]) - |> doFormat( - ~indentation=indent2Spaces, - ~languageConfiguration) == [|"{", "", " abc", "}"|]; + buffer(["{", " ", "abc", "}"]) + |> doFormat(~indentation=indent2Spaces, ~languageConfiguration) + == [|"{", "", " abc", "}"|]; }; - + let%test "increase / decrease indent (tabs)" = { - buffer(["{", "abc", "}"]) - |> doFormat( - ~indentation=indentTabs, - ~languageConfiguration) == [|"{", "\tabc", "}"|]; + buffer(["{", "abc", "}"]) + |> doFormat(~indentation=indentTabs, ~languageConfiguration) + == [|"{", "\tabc", "}"|]; }; }); - }; let format = (~indentation, ~languageConfiguration, ~startLineNumber, lines) => { diff --git a/src/Feature/Formatting/Feature_Formatting.re b/src/Feature/Formatting/Feature_Formatting.re index ab2a522264..3f97ddb8c3 100644 --- a/src/Feature/Formatting/Feature_Formatting.re +++ b/src/Feature/Formatting/Feature_Formatting.re @@ -311,13 +311,15 @@ let update = ~extHostClient, ~range= Range.{ - start: {line: Index.zero, column: Index.zero}, - stop: - { - line: - Oni_Core.Buffer.getNumberOfLines(buf) |> Index.fromZeroBased, - column: Index.zero, - }, + start: { + line: Index.zero, + column: Index.zero, + }, + stop: { + line: + Oni_Core.Buffer.getNumberOfLines(buf) |> Index.fromZeroBased, + column: Index.zero, + }, }, ); } diff --git a/src/Store/Features.re b/src/Store/Features.re index 56576b7fe5..59b401eccd 100644 --- a/src/Store/Features.re +++ b/src/Store/Features.re @@ -1,8 +1,11 @@ open Isolinear; open Oni_Core; +open Oni_Core.Utility; open Oni_Model; open Actions; +module Ext = Oni_Extensions; + module Internal = { let notificationEffect = (~kind, message) => { Feature_Notification.Effects.create(~kind, message) @@ -45,10 +48,18 @@ let update = state.layout |> Feature_Layout.activeEditor |> Feature_Editor.Editor.selectionOrCursorRange; + + let languageConfiguration = + maybeBuffer + |> OptionEx.flatMap(Oni_Core.Buffer.getFileType) + |> OptionEx.flatMap( + Ext.LanguageInfo.getLanguageConfiguration(state.languageInfo), + ) + |> Option.value(~default=LanguageConfiguration.default); + let (model', eff) = Feature_Formatting.update( - // TODO: - ~languageConfiguration=LanguageConfiguration.default, + ~languageConfiguration, ~configuration=state.configuration, ~maybeBuffer, ~maybeSelection=Some(selection), From f5c49b7945af4d87f6db22d6f8451ebaaff7ad7a Mon Sep 17 00:00:00 2001 From: Bryan Phelps Date: Mon, 29 Jun 2020 07:34:56 -0700 Subject: [PATCH 7/7] Remove test that no longer applies --- test/Core/LanguageConfigurationTest.re | 9 --------- 1 file changed, 9 deletions(-) diff --git a/test/Core/LanguageConfigurationTest.re b/test/Core/LanguageConfigurationTest.re index 596347e433..14cc56aa5f 100644 --- a/test/Core/LanguageConfigurationTest.re +++ b/test/Core/LanguageConfigurationTest.re @@ -152,15 +152,6 @@ describe("LanguageConfiguration", ({describe, test, _}) => { == Vim.AutoIndent.IncreaseIndent, true, ); - expect.equal( - LanguageConfiguration.toAutoIndent( - langConfig, - ~previousLine="def", - ~beforePreviousLine=None, - ) - == Vim.AutoIndent.DecreaseIndent, - true, - ); }); test("falls back to brackets", ({expect, _}) => { let parsedLangConfig =