From 028f15cce127360f29afa41754aab3816718492f Mon Sep 17 00:00:00 2001 From: Simon Van Casteren Date: Wed, 8 Jan 2020 12:12:24 +0100 Subject: Fixed smaller review remarks --- src/getinfo.sml | 8 ++++---- src/lspspec.sml | 4 +--- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/src/getinfo.sml b/src/getinfo.sml index d84f792b..5a0fe752 100644 --- a/src/getinfo.sml +++ b/src/getinfo.sml @@ -37,7 +37,7 @@ fun isPosIn (file: string) (row: int) (col: int) (span: ErrorMsg.span) = val start = #first span val end_ = #last span in - String.isSuffix file (#file span) + OS.Path.base file = OS.Path.base (#file span) andalso (#line start < row orelse #line start = row andalso #char start <= col) @@ -281,7 +281,7 @@ fun getInfo env str fileName {line = row, character = col} = let val distanceFromRow = Int.abs (#line (#first (#2 (#3 decl))) - row) val accDistanceFromRow = case accO of - NONE => 999 + NONE => Option.getOpt (Int.maxInt, 99999) | SOME acc => Int.abs (#line (#first (#2 (#3 acc))) - row) in if distanceFromRow < accDistanceFromRow andalso distanceFromRow <= 1 @@ -368,10 +368,10 @@ fun getInfo env str fileName {line = row, character = col} = { smallestgoodpart = NONE , smallest = { item = Str (str, { file = fileName , first = { line = 0, char = 0} - , last = { line = 99999, char = 0} }) + , last = { line = Option.getOpt (Int.maxInt, 99999), char = 0} }) , span = { file = fileName , first = { line = 0, char = 0} - , last = { line = 99999, char = 0} } + , last = { line = Option.getOpt (Int.maxInt, 99999), char = 0} } , env = env } } ( L.DStr (Compiler.moduleOf "fileName", 0, (L.SgnError, ErrorMsg.dummySpan), (str, {file = fileName, first = ErrorMsg.dummyPos, last = ErrorMsg.dummyPos})) diff --git a/src/lspspec.sml b/src/lspspec.sml index bbc78606..0d766056 100644 --- a/src/lspspec.sml +++ b/src/lspspec.sml @@ -8,9 +8,7 @@ structure LspSpec = struct (TextIO.output (TextIO.stdErr, str ^ "\n\n"); TextIO.flushOut TextIO.stdErr) fun trim (s: substring): substring = - Substring.dropr - (fn c => c = #" " orelse c = #"\n" orelse c = #"\r") - (Substring.dropl (fn c => c = #" " orelse c = #"\n" orelse c = #"\r") s) + Substring.dropr Char.isSpace (Substring.dropl Char.isSpace s) fun readHeader (): (string * string) option = let -- cgit v1.2.3