anchor.diff:      let mutable fsiOutputPID : int option = None
       let mutable lastSelectionSent : string option = None
   
  +    let mutable lastCd : string option = None
  +    let mutable lastCurrentFile : string option = None
  +
       let isPowershell () =
           let t = "terminal.integrated.shell.windows" |> Configuration.get ""
           t.ToLower().Contains "powershell"
   
  -    let sendCd () =
  -        let editor = window.activeTextEditor
  -        let file,dir =
  -            if  JS.isDefined editor then
  -                let file = editor.document.fileName
  +    let sendCd (textEditor: TextEditor) =
  +        let file, dir =
  +            if JS.isDefined textEditor then
  +                let file = textEditor.document.fileName
                   let dir = Path.dirname file
  -                file,dir
  +                file, dir
               else
                   let dir = workspace.rootPath
                   Path.join(dir, "tmp.fsx"), dir
  -        let msg1 = sprintf "# silentCd @\"%s\";;\n" dir
  -        let msg2 = (sprintf "# %d @\"%s\" \n" 1 file)
  -
  -
  -        fsiOutput |> Option.iter (fun n ->
  -            n.sendText(msg1, false)
  -            n.sendText(msg2, false)
  -            n.sendText(";;\n", false)
  -        )
  +
  +        match lastCd with
  +        | Some(cd) when cd = dir -> ()
  +        | _ ->
  +            let msg = sprintf "# silentCd @\"%s\";;\n" dir
  +            fsiOutput |> Option.iter (fun n -> n.sendText(msg, false))
  +            lastCd <- Some dir
  +
  +        match lastCurrentFile with
  +        | Some (currentFile) when currentFile = file -> ()
  +        | _ ->
  +            let msg = sprintf "# %d @\"%s\"\n;;\n" 1 file
  +            fsiOutput |> Option.iter (fun n -> n.sendText(msg, false))
  +            lastCurrentFile <- Some file
   
       let private start () =
           promise {
  
positive.code:     let private sendFile () =
          let editor = window.activeTextEditor
          let text = editor.document.getText ()
          send text
          |> Promise.suppress // prevent unhandled promise exception
          |> ignore
  
negative.code:     let private sendReferences () =
          window.activeTextEditor.document.fileName
          |> Project.tryFindLoadedProjectByFile
          |> Option.iter (fun p ->
              sendCd window.activeTextEditor
              p.References
              |> List.filter (fun n -> n.EndsWith "FSharp.Core.dll" |> not && n.EndsWith "mscorlib.dll" |> not )
              |> referenceAssemblies
              |> Promise.suppress
              |> ignore)
  
      let private handleCloseTerminal (terminal:Terminal) =
          fsiOutputPID
  