##// END OF EJS Templates
Fix #4777 and #7887...
Fix #4777 and #7887 The function in charge of actually converting cursor offset to CodeMirror line number and character number was actually crashing when the cursor was at the last character (loop until undefined, then access length of variable, which is undefined). This was hiding a bug in which when you would completer to a single completion pressing tab after as-you-type filtering, the completion would be completed twice. The logic that was supposed to detect whether or not all completions had a common prefix was actually faulty as the common prefix used to be a string but was then changed to an object. Hence the logic to check whether or not there was actually a common prefix was always true, even for empty string, leading to the deletion of the line (replace by '') in some cases.

File last commit:

r18605:9867311c
r20538:ae7f6d6a
Show More
test_clearoutput.py
33 lines | 1021 B | text/x-python | PythonLexer
"""
Module with tests for the clearoutput preprocessor.
"""
# Copyright (c) IPython Development Team.
# Distributed under the terms of the Modified BSD License.
from .base import PreprocessorTestsBase
from ..clearoutput import ClearOutputPreprocessor
class TestClearOutput(PreprocessorTestsBase):
"""Contains test functions for clearoutput.py"""
def build_preprocessor(self):
"""Make an instance of a preprocessor"""
preprocessor = ClearOutputPreprocessor()
preprocessor.enabled = True
return preprocessor
def test_constructor(self):
"""Can a ClearOutputPreprocessor be constructed?"""
self.build_preprocessor()
def test_output(self):
"""Test the output of the ClearOutputPreprocessor"""
nb = self.build_notebook()
res = self.build_resources()
preprocessor = self.build_preprocessor()
nb, res = preprocessor(nb, res)
assert nb.cells[0].outputs == []
assert nb.cells[0].execution_count is None